chatup-pro / Dockerfile
dvc890's picture
Update Dockerfile
d7e9f2b
# build front-end
FROM node:lts-alpine AS frontend
RUN npm install pnpm -g
WORKDIR /app
COPY ./package.json /app
COPY ./pnpm-lock.yaml /app
RUN pnpm install
COPY . /app
RUN pnpm run build
# build backend
FROM node:lts-alpine as backend
RUN npm install pnpm -g
WORKDIR /app
COPY /service/package.json /app
COPY /service/pnpm-lock.yaml /app
RUN pnpm install
COPY /service /app
RUN pnpm build
# service
FROM node:lts-alpine
RUN npm install pnpm -g
WORKDIR /app
COPY /service/package.json /app
COPY /service/pnpm-lock.yaml /app
RUN pnpm install --production && rm -rf /root/.npm /root/.pnpm-store /usr/local/share/.cache /tmp/*
COPY /service /app
COPY --from=frontend /app/replace-title.sh /app
RUN chmod +x /app/replace-title.sh
COPY --from=frontend /app/dist /app/public
COPY --from=backend /app/build /app/build
COPY --from=backend /app/src/utils/templates /app/build/templates
EXPOSE 3002
RUN --mount=type=secret,id=AUTH_SECRET_KEY,mode=0444,required=true
RUN --mount=type=secret,id=API_REVERSE_PROXY,mode=0444,required=true
RUN --mount=type=secret,id=OPENAI_ACCESS_TOKEN,mode=0444,required=true
RUN --mount=type=secret,id=MONGODB_URL,mode=0444,required=true
RUN --mount=type=secret,id=OPENAI_API_MODEL,mode=0444,required=true
RUN --mount=type=secret,id=PASSWORD_MD5_SALT,mode=0444,required=true
RUN --mount=type=secret,id=REGISTER_ENABLED,mode=0444,required=true
RUN --mount=type=secret,id=ROOT_USER,mode=0444,required=true
RUN --mount=type=secret,id=SITE_DOMAIN,mode=0444,required=true
RUN --mount=type=secret,id=SITE_TITLE,mode=0444,required=true
RUN --mount=type=secret,id=SMTP_HOST,mode=0444,required=true
RUN --mount=type=secret,id=SMTP_PASSWORD,mode=0444,required=true
RUN --mount=type=secret,id=SMTP_PORT,mode=0444,required=true
RUN --mount=type=secret,id=SMTP_TSL,mode=0444,required=true
RUN --mount=type=secret,id=SMTP_USERNAME,mode=0444,required=true
CMD ["sh", "-c", "pnpm run prod"]