CoolFace
Apppublic

MasterDee/chat-ui

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
Dockerfile89 linesDownload Raw Back to root
1# syntax=docker/dockerfile:12# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker3# you will also find guides on how best to write your Dockerfile4ARG INCLUDE_DB=false5 6# stage that install the dependencies7FROM node:20 as builder-production8 9WORKDIR /app10 11COPY --link --chown=1000 package-lock.json package.json ./12RUN --mount=type=cache,target=/app/.npm \13        npm set cache /app/.npm && \14        npm ci --omit=dev15 16FROM builder-production as builder17 18ARG APP_BASE=19ARG PUBLIC_APP_COLOR=blue20 21RUN --mount=type=cache,target=/app/.npm \22        npm set cache /app/.npm && \23        npm ci24 25COPY --link --chown=1000 . .26 27RUN npm run build28 29# mongo image30FROM mongo:latest as mongo31 32# image to be used if INCLUDE_DB is false33FROM node:20-slim as local_db_false34 35# image to be used if INCLUDE_DB is true36FROM node:20-slim as local_db_true37 38RUN apt-get update39RUN apt-get install gnupg curl -y40# copy mongo from the other stage41COPY --from=mongo /usr/bin/mongo* /usr/bin/42 43ENV MONGODB_URL=mongodb://localhost:2701744RUN mkdir -p /data/db45RUN chown -R 1000:1000 /data/db46 47# final image48FROM local_db_${INCLUDE_DB} as final49 50# build arg to determine if the database should be included51ARG INCLUDE_DB=false52ENV INCLUDE_DB=${INCLUDE_DB}53 54# svelte requires APP_BASE at build time so it must be passed as a build arg55ARG APP_BASE=56# tailwind requires the primary theme to be known at build time so it must be passed as a build arg57ARG PUBLIC_APP_COLOR=blue58 59 60# install dotenv-cli61RUN npm install -g dotenv-cli62 63# switch to a user that works for spaces64RUN userdel -r node65RUN useradd -m -u 1000 user66USER user67 68ENV HOME=/home/user \69	PATH=/home/user/.local/bin:$PATH70 71WORKDIR /app72 73# add a .env.local if the user doesn't bind a volume to it74RUN touch /app/.env.local75 76# get the default config, the entrypoint script and the server script77COPY --chown=1000 package.json /app/package.json78COPY --chown=1000 .env /app/.env79COPY --chown=1000 entrypoint.sh /app/entrypoint.sh80COPY --chown=1000 gcp-*.json /app/81 82#import the build & dependencies83COPY --from=builder --chown=1000 /app/build /app/build84COPY --from=builder --chown=1000 /app/node_modules /app/node_modules85 86RUN chmod +x /app/entrypoint.sh87 88CMD ["/bin/bash", "-c", "/app/entrypoint.sh"]89