Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ RUN --mount=type=cache,id=npm-build-stage-v4-${NPM_CACHE_KEY},target=/root/.npm,
npm ci --legacy-peer-deps --no-audit --no-fund && \
(npm cache verify 2>/dev/null || true)

# Checkpoint right after npm ci, before any per-workspace build runs: every
# workspace's node_modules is fully installed and final here. deps-production-*
# copies node_modules from this stage instead of the final `build` stage below
# — `COPY --from=<stage>` always waits for that stage's LAST instruction, and
# `RUN npm run build --workspace=packages/backend` (further down) intermittently
# corrupted BuildKit's cache-key resolution for a later COPY of
# packages/backend/node_modules from that same stage ("failed to calculate
# checksum of ref ...: not found" immediately after that RUN completed —
# reproduced consistently across buildx versions, with/without the GHA cache,
# concurrent and alone; never root-caused beyond decoupling the two). None of
# the per-workspace build scripts write into node_modules, so this is a
# behavior-neutral extraction point, not a functional change.
FROM build AS installed-deps
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
COPY packages/shared ./packages/shared
COPY packages/bot ./packages/bot
COPY packages/backend ./packages/backend
Expand Down Expand Up @@ -136,17 +150,17 @@ COPY packages/bot/package*.json ./packages/bot/
COPY packages/backend/package*.json ./packages/backend/
COPY packages/frontend/package*.json ./packages/frontend/

# Reuse already-compiled node_modules from build stage (avoids double @discordjs/opus
# compilation).
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/packages/shared/node_modules ./packages/shared/node_modules
# Reuse already-compiled node_modules from the pre-build checkpoint (avoids
# double @discordjs/opus compilation).
COPY --from=installed-deps /app/node_modules ./node_modules
COPY --from=installed-deps /app/packages/shared/node_modules ./packages/shared/node_modules

FROM deps-production-base AS deps-production-bot
COPY --from=build /app/packages/bot/node_modules ./packages/bot/node_modules
COPY --from=installed-deps /app/packages/bot/node_modules ./packages/bot/node_modules
RUN npm prune --omit=dev --legacy-peer-deps

FROM deps-production-base AS deps-production-backend
COPY --from=build /app/packages/backend/node_modules ./packages/backend/node_modules
COPY --from=installed-deps /app/packages/backend/node_modules ./packages/backend/node_modules
RUN npm prune --omit=dev --legacy-peer-deps

# Production stage — bot (full runtime with ffmpeg/opus/yt-dlp)
Expand Down
Loading