From 403437dafc6b69c2dbfc650823c68efa5abda507 Mon Sep 17 00:00:00 2001 From: Randall Stillwell Date: Mon, 27 Apr 2026 15:49:41 -0500 Subject: [PATCH] docker: bump web build heap to 2.5GB and serialize behind collab/mcp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 1.5GB heap cap was actually too aggressive for the Next 15 webpack compile on this monorepo: V8 spirals into GC churn near the cap, runs the host out of free memory, and oom-killer SIGKILLs the build (exit 255). With 4GB on the host now: - Cap V8 heap at 2.5GB (~70% of host RAM) — gives the compile real headroom while leaving room for kernel + dockerd + concurrent COPY layers from the collab/mcp runtime stages. - Add depends_on so the lighter collab + mcp services finish building before the web target starts its peak-memory compile, instead of fighting it for memory in parallel. Made-with: Cursor --- docker/Dockerfile | 8 +++++--- docker/docker-compose.coolify.yml | 13 ++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index f10a608..ceb15ca 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -51,9 +51,11 @@ COPY docker/next.config.docker.ts ./apps/web/next.config.ts ENV NEXT_TELEMETRY_DISABLED=1 ENV NODE_ENV=production -# Cap V8 heap so we get a clean JS OOM instead of a kernel SIGKILL (exit 255) -# if memory pressure spikes during the build on small hosts. -ENV NODE_OPTIONS=--max-old-space-size=1536 +# Give the Next.js webpack compile enough V8 heap headroom on the Coolify host. +# Sized to ~70% of the 4 GB host RAM so kernel + dockerd + concurrent runtime +# COPYs from collab/mcp still have breathing room. Below ~2 GB, the compile +# spirals into GC churn and gets oom-killed (exit 255 with no Docker error). +ENV NODE_OPTIONS=--max-old-space-size=2560 RUN pnpm exec turbo build --filter=@tasks/web diff --git a/docker/docker-compose.coolify.yml b/docker/docker-compose.coolify.yml index 7f7134c..15f3d8a 100644 --- a/docker/docker-compose.coolify.yml +++ b/docker/docker-compose.coolify.yml @@ -19,9 +19,13 @@ # # Build strategy: # All three services share docker/Dockerfile and select runtime via `target:`. -# The shared `deps` stage (pnpm install for the whole workspace) is hashed -# identically across targets, so BuildKit runs it ONCE even when web/collab/mcp -# build in parallel — keeps build-host RAM bounded. +# The shared `deps` stage is hashed identically across targets, so BuildKit +# runs `pnpm install` ONCE. +# +# `web` declares depends_on collab+mcp so Compose builds the lightweight +# services first and the heavy `next build` (peak ~2.5 GB heap) gets the host +# effectively to itself instead of fighting concurrent runtime-stage COPYs +# for memory. services: web: @@ -29,6 +33,9 @@ services: context: . dockerfile: docker/Dockerfile target: web + depends_on: + - collab + - mcp restart: unless-stopped environment: # Coolify FQDN magic var — set the domain in the Coolify UI for this service.