# Build stage
FROM golang:1.24-alpine AS builder

WORKDIR /app

# Install Hugo and Git
RUN apk add --no-cache hugo git

# Copy the repository contents
COPY . .

# Build the site with verbose output
RUN hugo --minify

# Pre-compress files for nginx gzip_static
RUN find /app/public -type f \( -name '*.html' -o -name '*.js' -o -name '*.css' -o -name '*.xml' -o -name '*.json' -o -name '*.svg' -o -name '*.woff' -o -name '*.woff2' -o -name '*.ttf' -o -name '*.otf' -o -name '*.eot' \) -exec gzip -k -9 {} \;

# Production stage
FROM nginx:alpine

# Copy the built site from builder
COPY --from=builder /app/public /usr/share/nginx/html

# Copy custom nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Expose port 80
EXPOSE 80

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