Dockerfile 文件配置
# build stage 1
FROM node:lts-alpine as build-stage1
WORKDIR /app
COPY package.json ./package.json
RUN npm config set registry https://registry.npmmirror.com \
&& npm install
# build stage 2
FROM node:lts-alpine as build-stage2
WORKDIR /app
COPY --from=build-stage1 /app /app
COPY . .
ENV NODE_ENV production
RUN npm config set registry https://registry.npmmirror.com &&\
npm run build &&\
# fix js error in IE
sed -i 's/catch{}/catch(e){}/g' `grep 'catch{}' -rl ./*` &&\
npm prune --production
# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage2 /app/dist /var/www/html
COPY conf/ssl /etc/nginx/ssl
COPY conf/nginx.conf /etc/nginx/nginx.conf
COPY conf/nginx-site.conf /etc/nginx/conf.d/default.conf
COPY conf/nginx-site-ssl.conf /etc/nginx/conf.d/default-ssl.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
# docker build -t node_nignx .