Dockerfile 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn \
  11. yarn install --frozen-lockfile
  12. # build resources
  13. FROM base as builder
  14. WORKDIR /app/web
  15. COPY --from=packages /app/web/ .
  16. COPY . .
  17. RUN yarn build
  18. # production stage
  19. FROM base as production
  20. ENV NODE_ENV production
  21. ENV EDITION SELF_HOSTED
  22. ENV DEPLOY_ENV PRODUCTION
  23. ENV CONSOLE_API_URL http://127.0.0.1:5001
  24. ENV APP_API_URL http://127.0.0.1:5001
  25. ENV PORT 3000
  26. # set timezone
  27. ENV TZ UTC
  28. RUN ln -s /usr/share/zoneinfo/${TZ} /etc/localtime \
  29. && echo ${TZ} > /etc/timezone
  30. # global runtime packages
  31. RUN yarn global add pm2 \
  32. && yarn cache clean
  33. WORKDIR /app/web
  34. COPY --from=builder /app/web/public ./public
  35. COPY --from=builder /app/web/.next/standalone ./
  36. COPY --from=builder /app/web/.next/static ./.next/static
  37. COPY docker/pm2.json ./pm2.json
  38. COPY docker/entrypoint.sh ./entrypoint.sh
  39. ARG COMMIT_SHA
  40. ENV COMMIT_SHA ${COMMIT_SHA}
  41. EXPOSE 3000
  42. ENTRYPOINT ["/bin/sh", "./entrypoint.sh"]