Dockerfile 575 B

1234567891011121314151617181920212223242526272829
  1. #FROM node:14.18.1-alpine as builder
  2. FROM node:lts-alpine as builder
  3. WORKDIR /code
  4. ADD package.json /code
  5. ENV NODE_OPTIONS=--openssl-legacy-provider
  6. RUN export NODE_OPTIONS
  7. RUN npm install
  8. ADD . /code
  9. RUN npm run build
  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 ./nginx.conf /etc/nginx/nginx.conf
  19. EXPOSE 80