FROM node:22-alpine AS build

WORKDIR /app

COPY package.json package-lock.json tsconfig.base.json ./
COPY apps/web/package.json apps/web/package.json
COPY packages/domain/package.json packages/domain/package.json
COPY services/api/package.json services/api/package.json
RUN npm ci

COPY packages/domain packages/domain
COPY apps/web apps/web

ARG APP_VARIANT=pro
ENV APP_VARIANT=$APP_VARIANT
RUN npm run build --workspace @cents/web

FROM nginx:1.27-alpine

COPY apps/web/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/apps/web/dist /usr/share/nginx/html

EXPOSE 80
