ARG MODEL_NAME ARG MODEL_PROMPT_TEMPLATE ARG APP_COLOR ARG APP_NAME FROM node:20 as chatui-builder ARG MODEL_NAME ARG APP_COLOR ARG APP_NAME ARG MODEL_PROMPT_TEMPLATE WORKDIR /app RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ git gettext && \ rm -rf /var/lib/apt/lists/* RUN git clone https://github.com/langtech-bsc/chat-ui.git --branch production WORKDIR /app/chat-ui RUN echo "" > /app/.env COPY .env.local.template .env.local.template RUN mkdir defaults ADD defaults /defaults RUN chmod -R 777 /defaults RUN --mount=type=secret,id=MONGODB_URL,mode=0444 \ --mount=type=secret,id=BASEURL,mode=0444 \ --mount=type=secret,id=BASEURL_SALAMANDRA_TOOLS,mode=0444 \ --mount=type=secret,id=HF_TOKEN,mode=0444 \ export MODEL_NAME="${MODEL_NAME:=$(cat /defaults/MODEL_NAME)}" \ && export MODEL_PROMPT_TEMPLATE="${MODEL_PROMPT_TEMPLATE:=$(cat /defaults/MODEL_PROMPT_TEMPLATE)}" \ && export APP_COLOR="${APP_COLOR:=$(cat /defaults/APP_COLOR)}" \ && export APP_NAME="${APP_NAME:=$(cat /defaults/APP_NAME)}" \ && export MONGODB_URL=$(cat /run/secrets/MONGODB_URL | grep '^') \ && export BASEURL=$(cat /run/secrets/BASEURL | grep '^') \ && export BASEURL_SALAMANDRA_TOOLS=$(cat /run/secrets/BASEURL_SALAMANDRA_TOOLS | grep '^') \ && export HF_TOKEN=$(cat /run/secrets/HF_TOKEN | grep '^') \ && envsubst < ".env.local.template" > ".env.local" \ && rm .env.local.template RUN --mount=type=cache,target=/app/.npm \ npm set cache /app/.npm && \ npm ci RUN npm run build FROM ghcr.io/huggingface/text-generation-inference:2.1.1 ARG MODEL_NAME ARG MODEL_PROMPT_TEMPLATE ARG APP_COLOR ARG APP_NAME ENV TZ=Europe/Paris \ PORT=3000 RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ gnupg \ curl \ gettext && \ rm -rf /var/lib/apt/lists/* COPY entrypoint.sh.template entrypoint.sh.template RUN mkdir defaults ADD defaults /defaults RUN chmod -R 777 /defaults RUN --mount=type=secret,id=MONGODB_URL,mode=0444 \ MODEL_NAME="${MODEL_NAME:="$(cat /defaults/MODEL_NAME)"}" && export MODEL_NAME \ && MODEL_PARAMS="${MODEL_PARAMS:="$(cat /defaults/MODEL_PARAMS)"}" && export MODEL_PARAMS \ && MODEL_PROMPT_TEMPLATE="${MODEL_PROMPT_TEMPLATE:="$(cat /defaults/MODEL_PROMPT_TEMPLATE)"}" && export MODEL_PROMPT_TEMPLATE \ && APP_COLOR="${APP_COLOR:="$(cat /defaults/APP_COLOR)"}" && export APP_COLOR \ && APP_NAME="${APP_NAME:="$(cat /defaults/APP_NAME)"}" && export APP_NAME \ && envsubst < "entrypoint.sh.template" > "entrypoint.sh" \ && rm entrypoint.sh.template RUN mkdir -p /data/db RUN chown -R 1000:1000 /data RUN curl -fsSL https://deb.nodesource.com/setup_20.x | /bin/bash - RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ nodejs && \ rm -rf /var/lib/apt/lists/* RUN mkdir /app RUN chown -R 1000:1000 /app RUN useradd -m -u 1000 user # Switch to the "user" user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH RUN npm config set prefix /home/user/.local RUN npm install -g pm2 RUN npm install -g dotenv-cli COPY --from=chatui-builder --chown=1000 /app/chat-ui/node_modules /app/node_modules COPY --from=chatui-builder --chown=1000 /app/chat-ui/package.json /app/package.json COPY --from=chatui-builder --chown=1000 /app/chat-ui/build /app/build COPY --from=chatui-builder --chown=1000 /app/chat-ui/.env /app/.env COPY --from=chatui-builder --chown=1000 /app/chat-ui/.env.local /app/.env.local ENTRYPOINT ["/bin/bash"] CMD ["entrypoint.sh"]