Reduce shared-server build concurrency and memory pressure

This commit is contained in:
2026-09-10 12:18:41 -04:00
parent 5c791164a3
commit f35de3b03c
3 changed files with 18 additions and 0 deletions
+2
View File
@@ -15,6 +15,8 @@ COPY . .
FROM source AS builder FROM source AS builder
ARG NEXT_PUBLIC_APP_URL ARG NEXT_PUBLIC_APP_URL
ENV NEXT_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL NEXT_TELEMETRY_DISABLED=1 ENV NEXT_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL NEXT_TELEMETRY_DISABLED=1
# Build-only resource controls for the shared Coolify VM; not runtime settings.
ENV NEXT_BUILD_CPUS=2 RAYON_NUM_THREADS=2 UV_THREADPOOL_SIZE=2 MALLOC_ARENA_MAX=2 NODE_OPTIONS=--max-old-space-size=1536
# Build-only placeholders; never copy production secrets into image layers. # Build-only placeholders; never copy production secrets into image layers.
RUN DATABASE_URL=postgres://build:build@127.0.0.1:5432/build BETTER_AUTH_SECRET=build-only-placeholder-secret-not-for-runtime BETTER_AUTH_URL=$NEXT_PUBLIC_APP_URL bun run --filter @album/web build RUN DATABASE_URL=postgres://build:build@127.0.0.1:5432/build BETTER_AUTH_SECRET=build-only-placeholder-secret-not-for-runtime BETTER_AUTH_URL=$NEXT_PUBLIC_APP_URL bun run --filter @album/web build
+4
View File
@@ -2,6 +2,10 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
output: "standalone", output: "standalone",
experimental: {
cpus: process.env.NEXT_BUILD_CPUS ? Math.max(1, Math.min(2, Number(process.env.NEXT_BUILD_CPUS) || 2)) : 2,
memoryBasedWorkersCount: false,
},
poweredByHeader: false, poweredByHeader: false,
images: { qualities: [75, 85] }, images: { qualities: [75, 85] },
async redirects() { async redirects() {
+12
View File
@@ -0,0 +1,12 @@
# Shared-server build safety
- Keep Coolify server concurrent builds at **1** (previously 2).
- Do not run manual Docker builds on the production VM alongside deployments.
Validate locally first; then push once and let the webhook build finish.
- The Docker builder caps Next page-generation workers and Rayon/libuv pools at
two. Node subprocesses have a 1536 MiB old-space ceiling. These are not a hard
total-memory limit: Bun, native allocations, and separate processes add overhead.
- Build controls are restricted to the builder stage; application runtime is
unchanged. The final image must pass the Sharp WebP smoke test.
- If memory pressure remains high, move builds to a separate builder rather than
increasing concurrency or running more diagnostic builds on the live VM.