# BUILDING 
FROM node:lts-alpine AS builder

WORKDIR /app

COPY . ./

# 这里可以做单独配置
# COPY docker/config.prod.ts ./src/config/config.prod.ts

# 国内可以打开下面一行加速，但有时候会出现503问题，暂时不用
# RUN npm config set registry https://registry.npm.taobao.org/ && npm config set sass-binary-site http://npm.taobao.org/mirrors/node-sass

RUN npm install && \
    # npm install typescript -g && \
    # npm run lint && \
    npm run build
    
# nginx
FROM nginx:stable-alpine
MAINTAINER vueadmin 

COPY --from=builder app/dist/  /usr/share/nginx/html/

# 自定义nginx.conf配置，比如history模式下，会404问题
RUN rm /etc/nginx/conf.d/default.conf
COPY docker/nginx.conf /etc/nginx/conf.d/