# ── MoreminiMore — Astro + Express + SES ─────────────────────────
# Build: npm run build  →  Runtime: node server.js (port 4321)
#
# Env vars:
#   SES_ACCESS_KEY_ID      (optional — SES email sending)
#   SES_SECRET_ACCESS_KEY  (optional)
#   SES_REGION             (default: ap-southeast-1)
#   PORT                   (default: 4321)

FROM node:22-bookworm-slim

WORKDIR /app

# ── Dependencies ──────────────────────────────────────────────────
COPY package.json package-lock.json ./
RUN npm ci

# ── Source + Build ───────────────────────────────────────────────
COPY . .
RUN npm run build

# ── Prune build-only deps (astro is ~200MB) ──────────────────────
# Keep: express, cors, nodemailer, @aws-sdk/client-ses
RUN npm prune --omit=dev 2>/dev/null; \
    npm ls --depth=0 2>/dev/null || true

# ── Runtime ──────────────────────────────────────────────────────
EXPOSE 4321
CMD ["node", "server.js"]
