Next.js standalone is single-process, so one container only used one CPU core. A load test hit a hard ceiling at ~60-65 req/sec with one core pegged at 133% while 3 cores sat idle. Now runs as pawfeed-1/2/3 behind an NPM least_conn upstream, verified via load test showing CPU spread evenly across all three replicas. Also caps the Prisma pg pool per-replica via DB_POOL_MAX so 3 replicas stay well under the Supabase pooler's connection limit.
72 lines
2.4 KiB
YAML
72 lines
2.4 KiB
YAML
# Shared config for the pawfeed-1/2/3 replicas (Gitea #26 scaling roadmap,
|
|
# see docker/SCALING-ROADMAP.md). Explicit services with fixed container
|
|
# names instead of `docker compose up --scale` — NPM's upstream block below
|
|
# needs predictable hostnames to load-balance across.
|
|
x-pawfeed-common: &pawfeed-common
|
|
build:
|
|
context: ..
|
|
dockerfile: docker/Dockerfile
|
|
args:
|
|
# Public vars needed at build time (baked into client bundle).
|
|
# Docker Compose reads these from docker/.env automatically.
|
|
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY}
|
|
NEXT_PUBLIC_SUPABASE_URL: ${NEXT_PUBLIC_SUPABASE_URL}
|
|
NEXT_PUBLIC_SENTRY_DSN: ${NEXT_PUBLIC_SENTRY_DSN}
|
|
# Sentry/GlitchTip source-map upload also runs during `npm run build`
|
|
# (withSentryConfig in next.config.ts), so it needs these as build
|
|
# args too — env_file below only reaches the running container, not
|
|
# the build stage. Leave unset to keep sourcemap upload disabled.
|
|
SENTRY_ORG: ${SENTRY_ORG}
|
|
SENTRY_PROJECT: ${SENTRY_PROJECT}
|
|
SENTRY_AUTH_TOKEN: ${SENTRY_AUTH_TOKEN}
|
|
# Resolves the sourcemap upload's release name. .git is excluded from
|
|
# the build context (see .dockerignore), so @sentry/nextjs can't
|
|
# auto-detect it via git and falls back to a literal "undefined"
|
|
# string, which GlitchTip's sourcemaps upload rejects. start.sh sets
|
|
# this from `git rev-parse --short HEAD` on the host before building.
|
|
SENTRY_RELEASE: ${SENTRY_RELEASE}
|
|
image: pawfeed:latest
|
|
restart: unless-stopped
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
NODE_ENV: production
|
|
REDIS_URL: redis://:${REDIS_PASSWORD}@redis:6379
|
|
# 3 replicas x 10 = 30 concurrent DB connections, well under the
|
|
# Supabase pooler's 200 max client connections (verified 2026-08-16).
|
|
DB_POOL_MAX: "10"
|
|
depends_on:
|
|
- redis
|
|
networks:
|
|
- default
|
|
- nginx_default
|
|
|
|
services:
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: pawfeed-redis
|
|
restart: unless-stopped
|
|
volumes:
|
|
- redis_data:/data
|
|
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}
|
|
|
|
pawfeed-1:
|
|
<<: *pawfeed-common
|
|
container_name: pawfeed-1
|
|
|
|
pawfeed-2:
|
|
<<: *pawfeed-common
|
|
container_name: pawfeed-2
|
|
|
|
pawfeed-3:
|
|
<<: *pawfeed-common
|
|
container_name: pawfeed-3
|
|
|
|
volumes:
|
|
redis_data:
|
|
|
|
networks:
|
|
default:
|
|
nginx_default:
|
|
external: true
|