# Multi-stage build для Astro static site.
# Build envs:
#   PUBLIC_SITE_URL  — публичный URL сайта (canonical/OG/sitemap), default https://test.food-market.kz
#   PUBLIC_APP_URL   — admin/API endpoint (для Header «Войти» и signup-формы)
FROM node:20-alpine AS build
WORKDIR /app
COPY package.json ./
# pnpm 10 — как в основной web-build'е
RUN corepack enable && corepack prepare pnpm@10 --activate
COPY pnpm-lock.yaml* ./
RUN pnpm install --frozen-lockfile || pnpm install
COPY . .
ARG PUBLIC_SITE_URL=https://test.food-market.kz
ARG PUBLIC_APP_URL=https://admin.food-market.kz
ENV PUBLIC_SITE_URL=$PUBLIC_SITE_URL
ENV PUBLIC_APP_URL=$PUBLIC_APP_URL
RUN pnpm build

FROM nginx:1.27-alpine AS runtime
COPY --from=build /app/dist /usr/share/nginx/html
COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
