Dockerfile_Prod 537 B

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