Skip to content

Commit a1443ce

Browse files
Userclaude
authored andcommitted
ci(docker): collapse build to a single npm ci to fix slow builds
The previous server/Dockerfile had parallel build + deps stages each running npm ci against ~500 Cosmos packages — they contended for registry bandwidth and the build was sitting at "deps 4/4" for 15+ minutes on cold cache. - Single build stage: npm ci once, run tsc, then npm prune --omit=dev to drop devDependencies before copying to runtime. - --ignore-scripts: blue-js-sdk and @coinbase/x402 postinstalls are inert (one is a console notice, the other has || true fallback); esbuild/fsevents only matter on dev. Skipping is safe and avoids any future hangs. - --no-audit --no-fund: less log noise, less work. - Add server/.dockerignore to keep build context lean. - Switch GHA cache export to mode=min: only the final layer is persisted, which is plenty for a single-stage install. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 979fd31 commit a1443ce

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ jobs:
4242
ghcr.io/${{ env.REPO }}:latest
4343
ghcr.io/${{ env.REPO }}:${{ github.sha }}
4444
cache-from: type=gha
45-
cache-to: type=gha,mode=max
45+
cache-to: type=gha,mode=min

server/.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules
2+
dist
3+
.env
4+
.env.*
5+
*.log
6+
test
7+
README.md
8+
.dockerignore
9+
Dockerfile
10+
docker-compose.yml

server/Dockerfile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@
44
FROM node:22-alpine AS build
55
WORKDIR /app
66
COPY package.json package-lock.json* ./
7-
RUN npm ci
7+
RUN npm ci --ignore-scripts --no-audit --no-fund --loglevel=error
88
COPY tsconfig.json ./
99
COPY src ./src
10-
RUN npm run build
11-
12-
# ─── Production deps only ───
13-
FROM node:22-alpine AS deps
14-
WORKDIR /app
15-
COPY package.json package-lock.json* ./
16-
RUN npm ci --omit=dev
10+
RUN npm run build \
11+
&& npm prune --omit=dev --ignore-scripts
1712

1813
# ─── Runtime ───
1914
FROM node:22-alpine AS runtime
@@ -24,7 +19,7 @@ ENV FACILITATOR_PORT=4021
2419

2520
RUN addgroup -S app && adduser -S app -G app
2621

27-
COPY --from=deps /app/node_modules ./node_modules
22+
COPY --from=build /app/node_modules ./node_modules
2823
COPY --from=build /app/dist ./dist
2924
COPY package.json ./
3025

0 commit comments

Comments
 (0)