FROM node:14.0.0 as builder
WORKDIR /app/tmr-group-admin

ENV HOSTIP = 'http://192.168.1.70:8081/'
#拷贝源码
COPY . .

RUN sed -i "s/SERVER_URL/$hostip/g" ./src/utils/configs.js

#安装依赖
RUN npm install --registry=https://registry.npm.taobao.org

# 开始构建
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