Skip to content

Commit ae9f95a

Browse files
authored
Merge pull request #254 from orionrobots/copilot/fix-253
Optimize Docker build context to fix slow compose up times in Copilot sessions
2 parents 09e0a18 + 1b967c9 commit ae9f95a

File tree

5 files changed

+88
-13
lines changed

5 files changed

+88
-13
lines changed

.dockerignore

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Aggressive .dockerignore for faster Docker builds
2+
# Most content is volume-mounted in docker-compose.yml for development
3+
14
_site
25
node_modules
36
.git
@@ -7,7 +10,50 @@ node_modules
710
.mega-linter.yml
811
.pre-commit-config.yaml
912
.shellcheckrc
10-
docker-compose.yml
13+
docker-compose*.yml
1114
serve.Dockerfile
1215
README.md
16+
17+
# Large directories that will be volume-mounted for development
18+
# These are the primary culprits for slow build context transfer
1319
_image_sources
20+
galleries
21+
content
22+
_drafts
23+
assets
24+
25+
# Other directories that will be volume-mounted
26+
products
27+
navigation_and_indexes
28+
error_pages
29+
admin
30+
_posts
31+
_data
32+
_includes
33+
34+
# Development and build artifacts
35+
dist
36+
*.log
37+
.DS_Store
38+
Thumbs.db
39+
40+
# IDE files
41+
.vscode
42+
.idea
43+
*.swp
44+
*.swo
45+
46+
# Temporary files
47+
.tmp
48+
tmp
49+
50+
# Keep essential files for build
51+
!package.json
52+
!package-lock.json
53+
!.eleventy.js
54+
!_config.yml
55+
!webpack.config.js
56+
!src/
57+
!tests/
58+
!.github/scripts/staging/default.conf
59+
!htaccess

.eleventyignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
./tests
55
./.github
66
Dockerfile
7+
DOCKER_OPTIMIZATION.md

Dockerfile

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1+
# Development build - minimal context needed since content is volume-mounted
12
FROM node:24-bullseye AS base
23

34
# Create app directory
45
WORKDIR /app/src
56

6-
# Install dependencies
7+
# Copy package files and install dependencies
8+
# This is all that's needed for development since source is volume-mounted
79
COPY package.json package-lock.json ./
810
RUN npm ci
911

12+
# Development debug build
1013
FROM base AS debug
1114

1215
RUN apt-get update && apt-get install -y \
1316
less \
1417
iputils-ping \
1518
dnsutils
1619

17-
# Copy app source for development
18-
COPY . /app/src
20+
# For development, source code is volume-mounted, not copied
1921

22+
# Broken link checker stage
2023
FROM dcycle/broken-link-checker:3 AS broken_link_checker
2124

25+
# Production HTTP server build - needs full content
2226
FROM httpd:2.4.64 AS httpd_serve
2327

2428
# Install curl for healthcheck
@@ -45,6 +49,7 @@ RUN if [ -f /tmp/build_context/httpd.conf ]; then \
4549
# Copy site content to web directory
4650
COPY . /usr/local/apache2/htdocs/
4751

52+
# Test build - needs some content for testing
4853
FROM base AS tests
4954

5055
# Install necessary packages for Playwright
@@ -61,13 +66,11 @@ RUN apt-get update && apt-get install -y \
6166
# Install Playwright browsers
6267
RUN npx playwright install chromium --with-deps
6368

64-
# Copy app source for testing
65-
COPY . /app/src
69+
# Copy test files
70+
COPY tests/ ./tests/
6671

6772
# Set default command to run BDD tests
6873
CMD ["npm", "run", "test:bdd"]
6974

75+
# Default stage for development - just the base with npm dependencies
7076
FROM base
71-
72-
# Copy app source for the final stage
73-
COPY . /app/src

dev.Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Minimal development Dockerfile
2+
# Only installs npm dependencies since content is volume-mounted
3+
FROM node:24-bullseye AS base
4+
5+
# Create app directory
6+
WORKDIR /app/src
7+
8+
# Copy package files and install dependencies
9+
COPY package.json package-lock.json ./
10+
11+
# Optimize npm ci for better performance in CI environments
12+
RUN npm ci --prefer-offline --no-audit --progress=false
13+
14+
# Development debug build
15+
FROM base AS debug
16+
17+
RUN apt-get update && apt-get install -y \
18+
less \
19+
iputils-ping \
20+
dnsutils
21+
22+
# Source code will be volume-mounted at runtime
23+
24+
# Default stage - just npm dependencies installed
25+
FROM base

docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
serve:
33
build:
44
context: .
5-
dockerfile: Dockerfile
5+
dockerfile: dev.Dockerfile
66
command: ["npm", "run", "serve"]
77
volumes:
88
- .:/app/src
@@ -16,7 +16,7 @@ services:
1616
dist:
1717
build:
1818
context: .
19-
dockerfile: Dockerfile
19+
dockerfile: dev.Dockerfile
2020
command: ["npm", "run", "dist"]
2121
volumes:
2222
- .:/app/src
@@ -25,7 +25,7 @@ services:
2525
build:
2626
build:
2727
context: .
28-
dockerfile: Dockerfile
28+
dockerfile: dev.Dockerfile
2929
command: ["npm", "run", "11ty"]
3030
volumes:
3131
- .:/app/src
@@ -61,7 +61,7 @@ services:
6161
shell:
6262
build:
6363
context: .
64-
dockerfile: Dockerfile
64+
dockerfile: dev.Dockerfile
6565
target: debug
6666
command: ["bash"]
6767
volumes:

0 commit comments

Comments
 (0)