diff --git a/.dockerignore b/.dockerignore index 8b5c83ec..350a36a7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,6 @@ +# Aggressive .dockerignore for faster Docker builds +# Most content is volume-mounted in docker-compose.yml for development + _site node_modules .git @@ -7,7 +10,50 @@ node_modules .mega-linter.yml .pre-commit-config.yaml .shellcheckrc -docker-compose.yml +docker-compose*.yml serve.Dockerfile README.md + +# Large directories that will be volume-mounted for development +# These are the primary culprits for slow build context transfer _image_sources +galleries +content +_drafts +assets + +# Other directories that will be volume-mounted +products +navigation_and_indexes +error_pages +admin +_posts +_data +_includes + +# Development and build artifacts +dist +*.log +.DS_Store +Thumbs.db + +# IDE files +.vscode +.idea +*.swp +*.swo + +# Temporary files +.tmp +tmp + +# Keep essential files for build +!package.json +!package-lock.json +!.eleventy.js +!_config.yml +!webpack.config.js +!src/ +!tests/ +!.github/scripts/staging/default.conf +!htaccess diff --git a/.eleventyignore b/.eleventyignore index bc33ac15..54cbec1b 100644 --- a/.eleventyignore +++ b/.eleventyignore @@ -4,3 +4,4 @@ ./tests ./.github Dockerfile +DOCKER_OPTIMIZATION.md diff --git a/Dockerfile b/Dockerfile index 41aa1d2e..44d1f90a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,15 @@ +# Development build - minimal context needed since content is volume-mounted FROM node:24-bullseye AS base # Create app directory WORKDIR /app/src -# Install dependencies +# Copy package files and install dependencies +# This is all that's needed for development since source is volume-mounted COPY package.json package-lock.json ./ RUN npm ci +# Development debug build FROM base AS debug RUN apt-get update && apt-get install -y \ @@ -14,11 +17,12 @@ RUN apt-get update && apt-get install -y \ iputils-ping \ dnsutils -# Copy app source for development -COPY . /app/src +# For development, source code is volume-mounted, not copied +# Broken link checker stage FROM dcycle/broken-link-checker:3 AS broken_link_checker +# Production HTTP server build - needs full content FROM httpd:2.4.64 AS httpd_serve # Install curl for healthcheck @@ -45,6 +49,7 @@ RUN if [ -f /tmp/build_context/httpd.conf ]; then \ # Copy site content to web directory COPY . /usr/local/apache2/htdocs/ +# Test build - needs some content for testing FROM base AS tests # Install necessary packages for Playwright @@ -61,13 +66,11 @@ RUN apt-get update && apt-get install -y \ # Install Playwright browsers RUN npx playwright install chromium --with-deps -# Copy app source for testing -COPY . /app/src +# Copy test files +COPY tests/ ./tests/ # Set default command to run BDD tests CMD ["npm", "run", "test:bdd"] +# Default stage for development - just the base with npm dependencies FROM base - -# Copy app source for the final stage -COPY . /app/src diff --git a/dev.Dockerfile b/dev.Dockerfile new file mode 100644 index 00000000..7165dbff --- /dev/null +++ b/dev.Dockerfile @@ -0,0 +1,25 @@ +# Minimal development Dockerfile +# Only installs npm dependencies since content is volume-mounted +FROM node:24-bullseye AS base + +# Create app directory +WORKDIR /app/src + +# Copy package files and install dependencies +COPY package.json package-lock.json ./ + +# Optimize npm ci for better performance in CI environments +RUN npm ci --prefer-offline --no-audit --progress=false + +# Development debug build +FROM base AS debug + +RUN apt-get update && apt-get install -y \ + less \ + iputils-ping \ + dnsutils + +# Source code will be volume-mounted at runtime + +# Default stage - just npm dependencies installed +FROM base diff --git a/docker-compose.yml b/docker-compose.yml index 72359e43..6c3ac0a8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ services: serve: build: context: . - dockerfile: Dockerfile + dockerfile: dev.Dockerfile command: ["npm", "run", "serve"] volumes: - .:/app/src @@ -16,7 +16,7 @@ services: dist: build: context: . - dockerfile: Dockerfile + dockerfile: dev.Dockerfile command: ["npm", "run", "dist"] volumes: - .:/app/src @@ -25,7 +25,7 @@ services: build: build: context: . - dockerfile: Dockerfile + dockerfile: dev.Dockerfile command: ["npm", "run", "11ty"] volumes: - .:/app/src @@ -61,7 +61,7 @@ services: shell: build: context: . - dockerfile: Dockerfile + dockerfile: dev.Dockerfile target: debug command: ["bash"] volumes: