# --- Build stage ---
FROM node:24-alpine3.21 AS builder
# Consider using the latest patch version for security updates
RUN apk update && apk upgrade

# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
RUN apk add --no-cache git

# Set workdir
WORKDIR /app

# Copy project files
COPY ./apps/docs .

# Install dependencies
RUN pnpm install

# Build VitePress site
RUN pnpm build

# --- Serve stage ---
FROM nginx:alpine

# Copy built site to nginx public folder
COPY --from=builder /app/.vitepress/dist /usr/share/nginx/html

# Expose port
EXPOSE 80

# Start nginx
CMD ["nginx", "-g", "daemon off;"]
