FROM node:14.0.0 as builder
WORKDIR /app/tmr-group-admin
#拷贝源码
COPY . .
#安装依赖
RUN npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
RUN npm install

# 开始构建
RUN npm run build:prod

# 第二阶段构建
FROM nginx:alpine

COPY --from=builder /app/tmr-group-admin/dist/ /usr/share/nginx/html/
COPY --from=builder /app/tmr-group-admin/default.conf.template /etc/nginx/templates/default.conf.template
EXPOSE 80

CMD ["/bin/sh", "-c", "sed -i \"s@<html@<html domain=\"$DOMAIN\"@\" /usr/share/nginx/html/index.html; nginx -g \"daemon off;\""]
