FROM node:24-alpine AS builder
ARG APP=admin
WORKDIR /src/web
RUN corepack enable
COPY web/package.json web/pnpm-lock.yaml web/pnpm-workspace.yaml ./
COPY web/apps ./apps
COPY web/packages ./packages
RUN CI=1 corepack pnpm@10.15.1 install --frozen-lockfile
RUN corepack pnpm@10.15.1 --filter @aigateway/${APP} build

FROM nginx:1.29-alpine
ARG APP=admin
COPY deploy/nginx-web.conf /etc/nginx/conf.d/default.conf
RUN sed -i "s/__APP__/${APP}/g" /etc/nginx/conf.d/default.conf
COPY --from=builder /src/web/apps/${APP}/dist /usr/share/nginx/html/${APP}
EXPOSE 80
