FROM node:24-alpine AS builder

WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1

COPY web/package.json web/package-lock.json ./
RUN npm ci --no-audit --fund=false

COPY editorial/ ./editorial/
COPY web/ ./
RUN npm run build

FROM joseluisq/static-web-server:2-alpine

ENV SERVER_ROOT=/public \
    SERVER_PORT=8080 \
    SERVER_LOG_LEVEL=warn \
    SERVER_DIRECTORY_LISTING=false \
    SERVER_COMPRESSION=true

COPY --from=builder /app/out /public

EXPOSE 8080

HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD wget -qO- http://127.0.0.1:8080/ >/dev/null || exit 1
