1f24ee8276
Hugo has no video processing, so FFmpeg runs in the builder stage
before hugo builds, compressing every content/**/*.mp4 in-place.
scripts/compress-videos.sh:
- H.264 CRF 28 + preset slow (good web compression)
- faststart for progressive streaming
- AAC 64k audio
- Only replaces source if output is actually smaller, so
already-lean videos are skipped
Dockerfile:
- apk adds ffmpeg alongside hugo in the builder stage
- RUN compress-videos.sh runs after COPY . . before pnpm build
(compressed files land in public/ via Hugo's copy of page bundles)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
733 B
Docker
36 lines
733 B
Docker
# Stage 1: Build
|
|
FROM node:22-alpine AS builder
|
|
|
|
# Install Hugo + FFmpeg (video compression)
|
|
RUN apk add --no-cache hugo ffmpeg
|
|
|
|
# Install pnpm
|
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files first (for layer caching)
|
|
COPY package.json pnpm-lock.yaml ./
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# Copy source files
|
|
COPY . .
|
|
|
|
# Compress MP4 videos in-place before Hugo builds
|
|
RUN sh scripts/compress-videos.sh content
|
|
|
|
# Build CSS and Hugo site
|
|
RUN pnpm build
|
|
|
|
# Stage 2: Production
|
|
FROM nginx:alpine
|
|
|
|
# Copy built site
|
|
COPY --from=builder /app/public /usr/share/nginx/html
|
|
|
|
# Copy nginx config
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["nginx", "-g", "daemon off;"] |