Dockerfile 1.4 KB

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