From 698d5a2b2a1e1307ed74d4eb83f38ccaabe875a8 Mon Sep 17 00:00:00 2001 From: Greg Date: Sun, 25 May 2025 16:58:40 +0200 Subject: [PATCH] Update Dockerfile to improve Hugo build logging and Nginx config --- Dockerfile | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index f75247a..2089de5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,30 +8,24 @@ RUN apk add --no-cache hugo WORKDIR /src # Copy the content of the project to the working directory +# This includes your Hugo site source, themes, and nginx.conf COPY . . -# Build the Hugo site with ignoreVendorPaths to avoid theme errors -RUN hugo --ignoreVendorPaths="**" --minify || mkdir -p /src/public && echo "My New Hugo Site

Welcome to My New Hugo Site!

This is a placeholder page. Add a theme or custom content to customize it.

" > /src/public/index.html +# Build the Hugo site. +# - Output will be in /src/public by default. +# - Added --verbose and --debug for more detailed build logs. +# - Removed the '|| mkdir ...' fallback to ensure Hugo errors stop the build and are visible. +RUN hugo --gc --minify --verbose --debug # Stage 2: Serve the site with Nginx FROM nginx:1.25-alpine -# Copy the built static site from the builder stage +# Copy the built static site from the builder stage's /src/public directory COPY --from=builder /src/public /usr/share/nginx/html -# Optional: Add custom Nginx configuration optimized for static sites -RUN echo 'server {\ - listen 80;\ - server_name _;\ - root /usr/share/nginx/html;\ - index index.html;\ - gzip on;\ - gzip_types text/plain text/css application/javascript image/svg+xml;\ - error_page 404 /404.html;\ - location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg)$ {\ - expires 30d;\ - }\ -}' > /etc/nginx/conf.d/default.conf +# Copy our custom Nginx configuration from the project root (copied in Stage 1) +# into the Nginx configuration directory. +COPY nginx.conf /etc/nginx/conf.d/default.conf # Expose port 80 EXPOSE 80