# ===========
# 1) BUILDER
# ===========
FROM node:20-alpine AS builder

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .
RUN npm run build

# ===========
# 2) RUNTIME
# ===========
FROM node:20-alpine

WORKDIR /app

COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY package*.json ./

# YAML + public (runtime needed!)
COPY --from=builder /app/src/content ./src/content
COPY --from=builder /app/public ./public

ENV HOST=0.0.0.0
ENV PORT=4321

EXPOSE 4321

CMD ["node", "./dist/server/entry.mjs"]