FROM johnpapa/angular-cli as angular
WORKDIR /app
COPY package.json /app/
RUN npm cache clear --force && npm install

COPY ./ /app/
ARG env=dev
ARG aot=--no-aot
RUN echo $env 
RUN echo $aot
RUN  if [ "$env" = "prod" ]; then ng build --$env --$aot; else ng build --$aot; fi

# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:1.13
COPY --from=angular /app/dist/ /usr/share/nginx/html
COPY --from=angular /app/static/ /usr/share/nginx/static
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
