# syntax=docker/dockerfile:1.7
#
# Single-shot build image for the Astro site. The production deployment uses
# this Dockerfile to produce apps/web/dist, then `docker-compose.yml` mounts
# that folder into a plain nginx:alpine container (so re-builds from the
# webhook don't require a `docker build` / push step).
#
# You only need this image if you want a self-contained static site image
# (e.g. for a registry). For the normal homeserver flow, just use
# `docker compose up -d --build web` — there is no `web` service to build.

FROM node:20-alpine AS base
RUN corepack enable && corepack prepare [email protected] --activate
WORKDIR /app

FROM base AS deps
COPY package.json pnpm-lock.yaml* ./
COPY ../../package.json ../../pnpm-workspace.yaml* ../../ ./
RUN pnpm install --frozen-lockfile

FROM base AS build
ENV PUBLIC_PAYLOAD_API=https://cms.softvowels.example
ENV PUBLIC_SITE_URL=https://softvowels.example
ENV PAYLOAD_API_INTERNAL=http://cms:3000
COPY --from=deps /app /app
COPY . .
RUN pnpm run build

FROM nginx:1.27-alpine AS runtime
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx-default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
