FROM node:22.14.0-alpine3.21 as build-stage
COPY ./ /app
WORKDIR /app

ENV YARN_REGISTRY https://registry.npmmirror.com/
RUN yarn install
COPY . .
ARG DEPLOY_ENV=prod
RUN if [ "$DEPLOY_ENV" = "test" ]; then \
        yarn build ; \
    else \
        yarn build ; \
    fi


# production stage
FROM nginx:1.27.4-alpine3.21 as production-stage
RUN mkdir /app
COPY --from=build-stage /app/dist /app
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
