FROM node:22-alpine AS base

RUN npm install -g pnpm@10

FROM base AS builder

WORKDIR /build

RUN echo "auto-install-peers=true" > .npmrc

COPY frontend/package.json frontend/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile

COPY frontend/ ./
RUN pnpm build

FROM nginx:alpine

COPY --from=builder /build/dist /usr/share/nginx/html
COPY frontend/nginx.conf /etc/nginx/conf.d/default.conf