Adds a dependency-free liveness endpoint (GET /api/health), a Docker healthcheck against it, and docker/rolling-deploy.sh which rebuilds the shared image once and restarts pawfeed-1/2/3 sequentially, gated on each becoming healthy before moving to the next. Verified zero-downtime via continuous curl monitoring through a full run against production.
81 lines
2.7 KiB
YAML
81 lines
2.7 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
|
|
# Used by docker/rolling-deploy.sh to know when a replica is ready to
|
|
# take traffic again before moving on to the next one. wget is the only
|
|
# HTTP client available in the node:22-alpine runner image.
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:3000/api/health"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 15s
|
|
|
|
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
|