# Multi-stage build to package static frontend assets
FROM node:20-alpine AS builder
WORKDIR /build
# Copy all repository contents for potential build steps (static site in this repo)
COPY . .
# Build step: place all repo contents into a dist directory without leaking build artifacts
RUN mkdir -p dist
RUN tar -c --exclude='./dist' -C . . | tar -x -C dist
FROM nginx:stable-alpine3.23
# Install a lightweight curl for healthchecks
RUN apk add --no-cache curl
# Copy the static site contents from the builder stage
COPY --from=builder /build/dist/ /usr/share/nginx/html
# Expose HTTP port
EXPOSE 80
# Healthcheck to ensure the server responds
HEALTHCHECK CMD curl -f http://localhost/ || exit 1
# Run nginx in the foreground
CMD ["nginx", "-g", "daemon off;"]