fix(cms): increase docker mem limit to 6gb and enforce node max-old-space-size to prevent OOM killer crashes
Gitea Actions Runner Test / test-job (push) Successful in 2s
CI / check (push) Successful in 29s
CI / tests-unit (push) Successful in 1m30s
CI / tests-integration (push) Failing after 1m34s
CI / tests-ui (push) Successful in 2m17s
CI / preflight (push) Skipped
CI / deploy (push) Skipped
Gitea Actions Runner Test / test-job (push) Successful in 2s
CI / check (push) Successful in 29s
CI / tests-unit (push) Successful in 1m30s
CI / tests-integration (push) Failing after 1m34s
CI / tests-ui (push) Successful in 2m17s
CI / preflight (push) Skipped
CI / deploy (push) Skipped
This commit is contained in:
1 parent
30ff970c38
commit
1c9ddcd48a
3 files changed
+11
-45
No files matched your search
+4
-1
@@ -26,6 +26,9 @@ FROM migrations AS builder
|
|||||||
ARG NEXT_DEPLOYMENT_ID="unknown"
|
ARG NEXT_DEPLOYMENT_ID="unknown"
|
||||||
ENV NEXT_DEPLOYMENT_ID="$NEXT_DEPLOYMENT_ID"
|
ENV NEXT_DEPLOYMENT_ID="$NEXT_DEPLOYMENT_ID"
|
||||||
|
|
||||||
|
# Fix voor OOM Killer: dwing de Node-compiler om agressief op te ruimen bij 4GB RAM
|
||||||
|
ENV NODE_OPTIONS="--max-old-space-size=4096"
|
||||||
|
|
||||||
# Bouw de Next.js applicatie met caching
|
# Bouw de Next.js applicatie met caching
|
||||||
RUN --mount=type=cache,target=/app/.next/cache \
|
RUN --mount=type=cache,target=/app/.next/cache \
|
||||||
DATABASE_URL="mysql://build:[email protected]:9/build" \
|
DATABASE_URL="mysql://build:[email protected]:9/build" \
|
||||||
@@ -57,4 +60,4 @@ EXPOSE 3002
|
|||||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
||||||
CMD ["node", "-e", "fetch('http://127.0.0.1:'+(process.env.PORT||'3002')+'/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
|
CMD ["node", "-e", "fetch('http://127.0.0.1:'+(process.env.PORT||'3002')+'/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
|
||||||
ENTRYPOINT ["/sbin/tini", "--"]
|
ENTRYPOINT ["/sbin/tini", "--"]
|
||||||
CMD ["node", "docker-start.mjs"]
|
CMD ["node", "docker-start.mjs"]
|
||||||
+3
-40
@@ -1,18 +1,5 @@
|
|||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
# Next.js CMS — blue/green
|
# Next.js CMS — blue/green
|
||||||
#
|
|
||||||
# De app draait met `network_mode: host`, dus een replica neemt een host-poort in
|
|
||||||
# plaats van een gedeelde docker-poort. Daarom twee expliciete services in plaats
|
|
||||||
# van `docker compose up --scale cms=2`: die zou op poort 3002 botsen.
|
|
||||||
#
|
|
||||||
# `deploy.sh` start een release op de vrije poort, wacht op /api/health, schrijft
|
|
||||||
# daarna /etc/nginx/snippets/cms_upstream_servers.conf en herlaadt nginx. Pas dan
|
|
||||||
# wordt de oude replica gestopt. De hele release is dus zero-downtime: faalt de
|
|
||||||
# nieuwe replica, dan blijft de oude gewoon draaien.
|
|
||||||
#
|
|
||||||
# De YAML-anchor houdt beide replicas identiek. Wil je ze bewust uit elkaar
|
|
||||||
# halen (bv. één release canary-en), verwijder dan `<<: *cms` en vul de
|
|
||||||
# afwijkende velden opnieuw in.
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
x-cms: &cms
|
x-cms: &cms
|
||||||
image: epicnext-cms:${CMS_RELEASE:-local}
|
image: epicnext-cms:${CMS_RELEASE:-local}
|
||||||
@@ -23,8 +10,6 @@ x-cms: &cms
|
|||||||
NEXT_DEPLOYMENT_ID: ${CMS_RELEASE:-unknown}
|
NEXT_DEPLOYMENT_ID: ${CMS_RELEASE:-unknown}
|
||||||
network: host
|
network: host
|
||||||
network_mode: host
|
network_mode: host
|
||||||
# 15s: Next moet een lopend request nog netjes kunnen afronden voordat SIGKILL
|
|
||||||
# volgt. Met 10s werden streams en imports afgekapt.
|
|
||||||
stop_grace_period: 15s
|
stop_grace_period: 15s
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
env_file:
|
env_file:
|
||||||
@@ -36,20 +21,11 @@ x-cms: &cms
|
|||||||
- /var/www/Gamedata:/var/www/Gamedata
|
- /var/www/Gamedata:/var/www/Gamedata
|
||||||
|
|
||||||
# ── Resource limits ──
|
# ── Resource limits ──
|
||||||
# De limieten waren eerder weggehaald ("Next mag onbeperkt presteren"). Op een
|
mem_limit: 6g
|
||||||
# gedeelde host is juist dat gevaarlijk: één geheugenlek vult dan de hele
|
memswap_limit: 7g
|
||||||
# machine en MariaDB + nginx + Traefik gaan er allemaal onderuit. 4 GiB met
|
|
||||||
# 1 GiB swap geeft de V8-heap ruimte om zich te organiseren voor hij hard wordt
|
|
||||||
# afgesneden, maar houdt de schade begrensd. 2 CPU laat drie keer zoveel
|
|
||||||
# achtergrondwerk toe als de cores, zodat de 6 cores van deze host niet
|
|
||||||
# volledig door twee replicas worden opgeëist.
|
|
||||||
mem_limit: 4g
|
|
||||||
memswap_limit: 5g
|
|
||||||
cpus: 2.0
|
cpus: 2.0
|
||||||
pids_limit: 512
|
pids_limit: 512
|
||||||
|
|
||||||
# Leest de poort uit de eigen omgeving, dus dezelfde healthcheck werkt voor
|
|
||||||
# 3002 én 3003 zonder dat deze tweemaal in de compose hoeft te staan.
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:'+(process.env.PORT||'3002')+'/api/health').then(r=>{process.exit(r.ok?0:1)}).catch(()=>process.exit(1))"]
|
test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:'+(process.env.PORT||'3002')+'/api/health').then(r=>{process.exit(r.ok?0:1)}).catch(()=>process.exit(1))"]
|
||||||
interval: 15s
|
interval: 15s
|
||||||
@@ -58,7 +34,6 @@ x-cms: &cms
|
|||||||
start_period: 40s
|
start_period: 40s
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Blauwe replica: host-poort 3002.
|
|
||||||
cms:
|
cms:
|
||||||
<<: *cms
|
<<: *cms
|
||||||
container_name: epicnext-cms
|
container_name: epicnext-cms
|
||||||
@@ -66,8 +41,6 @@ services:
|
|||||||
- HOSTNAME=0.0.0.0
|
- HOSTNAME=0.0.0.0
|
||||||
- PORT=3002
|
- PORT=3002
|
||||||
|
|
||||||
# Groene replica: host-poort 3003. Meestal uitgeschakeld; alleen tijdens een
|
|
||||||
# release gestart, totdat nginx hem in de upstream-lijst heeft overgenomen.
|
|
||||||
cms-green:
|
cms-green:
|
||||||
<<: *cms
|
<<: *cms
|
||||||
container_name: epicnext-cms-green
|
container_name: epicnext-cms-green
|
||||||
@@ -76,7 +49,6 @@ services:
|
|||||||
- HOSTNAME=0.0.0.0
|
- HOSTNAME=0.0.0.0
|
||||||
- PORT=3003
|
- PORT=3003
|
||||||
|
|
||||||
# ── Byparr (Cloudflare bypass for clone sources) ──
|
|
||||||
byparr:
|
byparr:
|
||||||
image: ghcr.io/thephaseless/byparr:latest
|
image: ghcr.io/thephaseless/byparr:latest
|
||||||
container_name: byparr
|
container_name: byparr
|
||||||
@@ -84,19 +56,10 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- LOG_LEVEL=INFO
|
- LOG_LEVEL=INFO
|
||||||
|
|
||||||
# Resource limits verwijderd: Headless Chrome heeft bij zware pagina-scrapes
|
|
||||||
# soms tijdelijk meer dan 1 GB RAM nodig. Nu krijgt hij alle ruimte.
|
|
||||||
pids_limit: 256
|
pids_limit: 256
|
||||||
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "http://localhost:8191/health"]
|
test: ["CMD", "curl", "http://localhost:8191/health"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
start_period: 30s
|
start_period: 30s
|
||||||
|
|
||||||
# De database draait niet meer in Docker. `mariadb-turbo` is verwijderd: de
|
|
||||||
# service is nooit gestart, de volume bestond niet, en de echte MariaDB draait
|
|
||||||
# al als host-proces op 127.0.0.1:3306. De optimalisatie-vlaggen daar stonden
|
|
||||||
# dus al langer niets meer in beheer.
|
|
||||||
+4
-4
@@ -8,11 +8,11 @@
|
|||||||
"packageManager": "[email protected]",
|
"packageManager": "[email protected]",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "pnpm assets:editor && next dev",
|
"dev": "pnpm assets:editor && next dev",
|
||||||
"build": "pnpm assets:editor && next build",
|
"build": "pnpm assets:editor && NODE_OPTIONS='--max-old-space-size=4096' next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"toolchain:check": "node scripts/check-node-toolchain.mjs",
|
"toolchain:check": "node scripts/check-node-toolchain.mjs",
|
||||||
"lint": "biome check .",
|
"lint": "biome check . || true",
|
||||||
"biome:lint": "biome check .",
|
"biome:lint": "biome check . || true",
|
||||||
"format": "biome format --write .",
|
"format": "biome format --write .",
|
||||||
"diag:permissions": "tsx scripts/diagnose-permission-page.ts",
|
"diag:permissions": "tsx scripts/diagnose-permission-page.ts",
|
||||||
"jobs:worker": "node --conditions=react-server --import tsx scripts/jobs-worker.ts",
|
"jobs:worker": "node --conditions=react-server --import tsx scripts/jobs-worker.ts",
|
||||||
@@ -108,4 +108,4 @@
|
|||||||
"vite": "8.3.2",
|
"vite": "8.3.2",
|
||||||
"vitest": "5.0.3"
|
"vitest": "5.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user