chat-v3 / Dockerfile
muryshev's picture
Update Dockerfile
6688341
ARG MODEL_NAME
ARG MODEL_PARAMS
ARG APP_COLOR
ARG APP_NAME
#test
FROM node:19 as chatui-builder
ARG MODEL_NAME
ARG MODEL_PARAMS
ARG APP_COLOR
ARG APP_NAME
ARG SIMILARITY_API_URL
ARG SIMILARITY_THRESHOLD
ARG WEB_SEARCH_TEMPLATE
ARG SAIGA_BYPASS_WEBSEARCH_QUERY
WORKDIR /app
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
gettext && \
rm -rf /var/lib/apt/lists/*
#RUN git clone https://github.com/amatenkov/chat-ui.git
COPY ./chat-ui /app/chat-ui
WORKDIR /app/chat-ui
COPY .env.local.template .env.local.template
RUN mkdir defaults
ADD defaults /defaults
RUN chmod -R 777 /defaults
RUN --mount=type=cache,target=/app/.npm \
npm set cache /app/.npm && \
npm ci
RUN --mount=type=secret,id=DOTENV_LOCAL,dst=.env.local \
echo "This is a cache-busting instruction: $(date +%s)" && \
npm run build
FROM ghcr.io/huggingface/text-generation-inference:0.9.4
ARG MODEL_NAME
ARG MODEL_PARAMS
ARG APP_COLOR
ARG APP_NAME
ARG SIMILARITY_API_URL
ARG SIMILARITY_THRESHOLD
ARG WEB_SEARCH_TEMPLATE
ARG SAIGA_BYPASS_WEBSEARCH_QUERY
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 \
--mount=type=secret,id=SERPAPI_KEY,mode=0444,required=true \
MODEL_NAME="${MODEL_NAME:="$(cat /defaults/MODEL_NAME)"}" && export MODEL_NAME \
&& MODEL_PARAMS="${MODEL_PARAMS:="$(cat /defaults/MODEL_PARAMS)"}" && export MODEL_PARAMS \
&& APP_COLOR="${APP_COLOR:="$(cat /defaults/APP_COLOR)"}" && export APP_COLOR \
&& APP_NAME="${APP_NAME:="$(cat /defaults/APP_NAME)"}" && export APP_NAME \
&& export SIMILARITY_API_URL \
&& export SIMILARITY_THRESHOLD \
&& export WEB_SEARCH_TEMPLATE \
&& export SAIGA_BYPASS_WEBSEARCH_QUERY \
&& SERPAPI_KEY=$(cat /run/secrets/SERPAPI_KEY) && export SERPAPI_KEY \
&& MONGODB_URL=$(cat /defaults/MONGODB_URL) && export MONGODB_URL && \
envsubst < "entrypoint.sh.template" > "entrypoint.sh" \
&& rm entrypoint.sh.template
RUN curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
--dearmor
RUN echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
mongodb-org && \
rm -rf /var/lib/apt/lists/*
RUN mkdir -p /data/db
RUN chown -R 1000:1000 /data
RUN curl -fsSL https://deb.nodesource.com/setup_19.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
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
ENTRYPOINT ["/bin/bash"]
CMD ["entrypoint.sh"]