Dockerfile 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # base image
  2. FROM node:20.11-alpine3.19 AS base
  3. LABEL maintainer="takatost@gmail.com"
  4. RUN apk add --no-cache tzdata
  5. # install packages
  6. FROM base as packages
  7. WORKDIR /app/web
  8. COPY package.json .
  9. COPY yarn.lock .
  10. RUN yarn install --frozen-lockfile
  11. # build resources
  12. FROM base as builder
  13. WORKDIR /app/web
  14. COPY --from=packages /app/web/ .
  15. COPY . .
  16. RUN yarn build
  17. # production stage
  18. FROM base as production
  19. ENV NODE_ENV production
  20. ENV EDITION SELF_HOSTED
  21. ENV DEPLOY_ENV PRODUCTION
  22. ENV CONSOLE_API_URL http://127.0.0.1:5001
  23. ENV APP_API_URL http://127.0.0.1:5001
  24. ENV PORT 3000
  25. # set timezone
  26. ENV TZ UTC
  27. RUN ln -s /usr/share/zoneinfo/${TZ} /etc/localtime \
  28. && echo ${TZ} > /etc/timezone
  29. # global runtime packages
  30. RUN yarn global add pm2 \
  31. && yarn cache clean
  32. WORKDIR /app/web
  33. COPY --from=builder /app/web/public ./public
  34. COPY --from=builder /app/web/.next/standalone ./
  35. COPY --from=builder /app/web/.next/static ./.next/static
  36. COPY docker/pm2.json ./pm2.json
  37. COPY docker/entrypoint.sh ./entrypoint.sh
  38. ARG COMMIT_SHA
  39. ENV COMMIT_SHA ${COMMIT_SHA}
  40. EXPOSE 3000
  41. ENTRYPOINT ["/bin/sh", "./entrypoint.sh"]