FROM node:16 AS compile-image

WORKDIR /opt/ng
COPY package.json /opt/ng/package.json
RUN npm install
RUN npm install -g @angular/cli
ENV PATH="./node_modules/.bin:$PATH"

COPY . ./
RUN ng build --configuration production --base-href /cm-finance-web/ --deploy-url /cm-finance-web/

FROM nginx
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=compile-image /opt/ng/dist/cm-finance-web /usr/share/nginx/html
