FROM node:20-alpine AS builder

WORKDIR /app

RUN corepack enable && corepack prepare pnpm@latest --activate

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

COPY . .

ARG PUBLIC_WORKER_URL
ARG PUBLIC_UPLOAD_SECRET
ENV PUBLIC_WORKER_URL=$PUBLIC_WORKER_URL
ENV PUBLIC_UPLOAD_SECRET=$PUBLIC_UPLOAD_SECRET

RUN pnpm run build

FROM nginx:alpine

COPY --from=builder /app/dist /usr/share/nginx/html

EXPOSE 80
