VERSION 0.8

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

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

build:
    FROM +deps
    COPY . .
    RUN pnpm build
    SAVE ARTIFACT dist AS LOCAL ./dist

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

    FROM +deps
    COPY . .

    ENV HOST=0.0.0.0
    ENV PORT=4321
    EXPOSE 4321

    SAVE IMAGE $IMAGE_NAME:$TAG
    SAVE IMAGE --push $REGISTRY/$IMAGE_NAME:$TAG

# image:
#     ARG REGISTRY="registry.mangopig.tech"
#     ARG IMAGE_NAME="boost-ai/demo"
#     ARG TAG="latest"

#     FROM nginx:1.29-alpine
#     COPY +build/dist /tmp/dist
#     RUN rm -rf /usr/share/nginx/html/* && cp -R /tmp/dist/. /usr/share/nginx/html/
#     COPY nginx.conf /etc/nginx/conf.d/default.conf
#     EXPOSE 80
#     SAVE IMAGE boost-ai/demo-frontend:latest
#     SAVE IMAGE --push $REGISTRY/$IMAGE_NAME:$TAG
