FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json ./
RUN npm ci --only=production --ignore-scripts || npm install --only=production --ignore-scripts
COPY src/ ./src/
RUN if npm run minify 2>/dev/null; then echo "Minified"; else echo "Skipping minify"; fi

FROM nginx:alpine
COPY --from=builder /app/src/ /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/conf.d/default.conf
RUN echo '{"status":"ok"}' > /usr/share/nginx/html/health.json
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s \
  CMD curl -f http://localhost:80/health.json || exit 1

LABEL com.phantom.service="landing" \
      com.phantom.version="1.0.0"
