Dockerfile_Prod 597 B

123456789101112131415161718192021222324252627
  1. FROM node:lts-alpine as builder
  2. WORKDIR /code
  3. ADD package.json /code
  4. RUN npm config set registry https://registry.npmmirror.com
  5. RUN npm install
  6. ADD . /code
  7. RUN npm run build:prod
  8. #环境变量写在build后面否则找不到指令
  9. ENV PROJECT_ENV production
  10. ENV NODE_ENV production
  11. FROM nginx:alpine
  12. # 设置时区
  13. #RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  14. #RUN echo 'Asia/Shanghai' >/etc/timezone
  15. COPY --from=builder code/dist/ /usr/share/nginx/html/
  16. COPY ./index.html /usr/share/nginx/html/index.html
  17. COPY ./docker/prod/nginx.conf /etc/nginx/nginx.conf
  18. EXPOSE 80