# build environment: run https://mherman.org/blog/dockerizing-a-react-app/

FROM node:14.15.3 as build
WORKDIR /app
COPY .npmrc .npmrc
COPY package-lock.json .
COPY package.json .
RUN npm ci
RUN npm install -g @angular/cli@11.1.4
COPY . .
RUN ng build esp-common-ui --configuration b2c --base-href /comm --deploy-url /comm/ --output-path=comm

# production environment
FROM nginx
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/comm /usr/share/nginx/html/comm
COPY docker/config.js /usr/share/nginx/html/comm
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

# build environment: run https://mherman.org/blog/dockerizing-a-react-app/
