Update Dockerfile to improve Hugo build logging and Nginx config
This commit is contained in:
parent
478b1f5b75
commit
698d5a2b2a
26
Dockerfile
26
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 "<html><head><title>My New Hugo Site</title></head><body><h1>Welcome to My New Hugo Site!</h1><p>This is a placeholder page. Add a theme or custom content to customize it.</p></body></html>" > /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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user