Dockerfile 787 B

1234567891011121314151617181920212223242526272829303132333435
  1. FROM node:alpine AS builder
  2. WORKDIR /www/backend
  3. # 切换阿里云源
  4. RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories && \
  5. apk update && \
  6. apk add --no-cache tzdata # 时区
  7. COPY . .
  8. RUN pwd && ls -la
  9. #
  10. RUN yarn install --production=false
  11. RUN yarn build
  12. RUN pwd && ls -la
  13. FROM node:alpine AS runner
  14. WORKDIR /www/backend
  15. ENV TZ=Asia/Shanghai
  16. ENV NODE_ENV=production
  17. ENV APP_PATH=/usr/src/app
  18. ENV DEBUG=moka:*
  19. # 时区
  20. COPY --from=builder /usr/share/zoneinfo/${TZ} /etc/localtime
  21. COPY --from=builder /www/backend/package.json /www/backend/yarn.lock ./
  22. RUN yarn install
  23. COPY --from=builder /www/backend/dist ./dist/
  24. COPY --from=builder /www/backend/config ./config/
  25. RUN pwd && ls -la
  26. EXPOSE 3000
  27. CMD yarn start 2>&1 | tee ./runtime/app.log