FROM node:20-alpine AS build-stage
WORKDIR /app


COPY package*.json ./

RUN npm install

COPY . .
RUN npm run build


FROM nginx:stable-alpine AS production-stage

RUN apk add --no-cache bash

WORKDIR /app
COPY package*.json ./

COPY --from=build-stage /app/dist /usr/share/nginx/html
COPY --from=build-stage /app/public/icons /usr/share/nginx/html/icons
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY BuildConfig.sh /docker-entrypoint.d/10-build-config.sh
RUN chmod a+x /docker-entrypoint.d/10-build-config.sh
EXPOSE $FRONTEND_PORT

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