FROM alpine:latest AS build
WORKDIR /usr/src/

RUN apk update
RUN apk add --no-cache nodejs npm

RUN npm install -g typescript@4.0.7 && \
    npm install -g @angular/cli@11.2.9 || true --fo

ENV NG_CLI_ANALYTICS=ci

COPY . .

ARG ANGULAR_CONFIGURATION=production

RUN npm install --force
RUN ng build --configuration=$ANGULAR_CONFIGURATION --stats-json --source-map=false

FROM nginx:mainline-alpine

WORKDIR /usr/bin/

COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build /usr/src/dist/color-recipes-explorer-frontend/ .

ARG CRE_PORT=80
EXPOSE $CRE_PORT

CMD ["nginx", "-g", "daemon off;"]