FROM node:14.0.0 as builder
WORKDIR /app/tmr-group-admin
#拷贝源码
COPY . .

ENV HOSTIP = 'http://127.0.0.1:8081/'

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

RUN ls -l && pwd
RUN cat ./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
