VERSION 0.8

frontend-node-base:
    FROM node:24.12.0-alpine
    WORKDIR /workspace/BoostAI/Frontend
    RUN corepack enable && corepack prepare pnpm@10.24.0 --activate
    COPY Frontend/package.json Frontend/pnpm-lock.yaml ./

frontend-deps:
    FROM +frontend-node-base
    RUN pnpm install --frozen-lockfile

frontend-prod-image:
    ARG IMAGE_NAME="boost-ai/demo-frontend-prod-a"
    ARG TAG="latest"

    FROM +frontend-deps
    COPY Frontend/. ./
    COPY Mock-Data ../Mock-Data
    RUN pnpm build

    ENV NODE_ENV=production
    ENV HOST=0.0.0.0
    ENV PORT=3000
    ENV NITRO_HOST=0.0.0.0
    ENV NITRO_PORT=3000
    EXPOSE 3000

    ENTRYPOINT ["node", ".output/server/index.mjs"]

    SAVE IMAGE $IMAGE_NAME:$TAG

frontend-prod-image-push:
    ARG REGISTRY="registry.mangopig.tech"
    ARG IMAGE_NAME="boost-ai/demo-frontend-prod-a"
    ARG TAG="latest"

    FROM +frontend-prod-image --IMAGE_NAME=$IMAGE_NAME --TAG=$TAG
    SAVE IMAGE --push $REGISTRY/$IMAGE_NAME:$TAG
