ShowerLoop-cc/docker/showerloop/Dockerfile

42 lines
1.4 KiB
Docker

# Stage 1: Build Hugo site
FROM alpine:latest AS hugo-builder
# Install necessary dependencies (Hugo, Git, Node.js, and npm)
RUN apk add --no-cache hugo git nodejs npm
# Copy our enhanced Caddyfile
COPY Caddyfile.default.template /etc/caddy/Caddyfile.override
# Set working directory
WORKDIR /site
# Copy the Hugo source files
COPY public/ /site
# Install PostCSS and its dependencies locally and update browserslist
RUN cd /site && npm init -y && \
npm install --save-dev postcss postcss-cli autoprefixer && \
npm install --save-dev caniuse-lite && \
npm update caniuse-lite browserslist
# Build the Hugo site for production with optimizations
# Disable GitInfo, enable minification, and set production environment
RUN mkdir /public && \
cd /site && \
HUGO_ENABLEGITINFO=false \
HUGO_ENV=production \
npm run build:prod && \
cp -r /site/public/* /public/
# Stage 2: Production image with prebuilt static files
FROM git.nixc.us/colin/container-base:production-nixiusstatic
# Copy the built site from the first stage
COPY --from=hugo-builder /public /srv
# Copy our enhanced Caddyfile for development
COPY Caddyfile.default.template /etc/caddy/Caddyfile.override
# Add health check endpoint for production monitoring
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -q --spider http://localhost/healthcheck.txt || exit 1