Dockerfile 654 B

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