Adds a dedicated Node 22 + ws arena server (src/arena) that owns live Ordnance Disposal matches: drift-corrected 20Hz tick loop with capped catch-up and tick-drift logging, per-socket snapshot fan-out, 30s jose ticket auth, and awards via the idempotent results callback route. Client gains a transport abstraction (transport.ts): WsTransport first when NEXT_PUBLIC_ARENA_URL is baked into the bundle, HttpTransport (today's actions + SSE + guarded poll, behavior unchanged) as automatic fallback after two connection failures or a 5s setup timeout; absent env var means pure HTTP (kill switch / rollback path). Next actions proxy the match lifecycle to the arena when ARENA_SECRET + ARENA_INTERNAL_URL are set; the in-process registry stays untouched as the default backend. Deploy wiring: runner-arena Dockerfile target, compose service, env docs, DEPLOYMENT.md checklist. Tests: arena module suite (19), live server WS suite (3), prediction harness ws-grade latency scenario.
97 lines
3.3 KiB
YAML
97 lines
3.3 KiB
YAML
# Local full-stack dev compose.
|
|
#
|
|
# `docker compose up --build` boots the Next.js + Payload app next to a
|
|
# dedicated Postgres and mounts `./media` as the Payload upload volume, so
|
|
# you get the exact same shape as the Coolify deployment without needing a
|
|
# running Coolify cluster.
|
|
#
|
|
# In production (Coolify) we DO NOT use this file — Coolify builds the
|
|
# Dockerfile directly per environment and provisions its own managed
|
|
# PostgreSQL service. DATABASE_URI is injected as an env var per
|
|
# environment by Coolify. See DEPLOYMENT.md.
|
|
|
|
services:
|
|
app:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
image: polaris-task-force:local
|
|
container_name: polaris-task-force-app
|
|
# In Coolify these come from the per-environment env vars configured in
|
|
# the Coolify UI; here we read a local .env (see .env.example).
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
# Override the host DB hostname with the compose service name so
|
|
# the app reaches the bundled postgres instead of localhost.
|
|
# DATABASE_URI is rewritten below — strip any user-provided value.
|
|
NODE_ENV: production
|
|
DATABASE_URI: postgres://${POSTGRES_USER:-ptfapp}:${POSTGRES_PASSWORD:-polaristaskforcedb}@postgres:5432/${POSTGRES_DB:-ptf-app-dev}
|
|
ports:
|
|
- "${APP_PORT:-3000}:3000"
|
|
volumes:
|
|
# Persist Payload uploads between rebuilds locally.
|
|
- ./media:/app/media
|
|
# Map tile pyramids (gitignored; generated locally, uploaded in prod).
|
|
- ./public/tiles:/app/public/tiles
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:3000/api/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
start_period: 60s
|
|
retries: 3
|
|
restart: unless-stopped
|
|
|
|
# Arena: dedicated real-time match server for Ordnance Disposal (src/arena).
|
|
# Optional: with ARENA_SECRET/ARENA_INTERNAL_URL unset the app runs exactly
|
|
# as before on its in-process registry. When set (see .env), the app proxies
|
|
# the match lifecycle here and browsers connect over ws://localhost:4100/ws
|
|
# (set NEXT_PUBLIC_ARENA_URL=ws://localhost:4100 in .env for local WS tests).
|
|
arena:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
target: runner-arena
|
|
image: polaris-task-force-arena:local
|
|
container_name: polaris-task-force-arena
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
# Results callbacks go back into the app container by service name.
|
|
APP_URL: http://app:3000
|
|
ports:
|
|
- "${ARENA_PORT:-4100}:4100"
|
|
depends_on:
|
|
- app
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:4100/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
start_period: 20s
|
|
retries: 3
|
|
restart: unless-stopped
|
|
|
|
postgres:
|
|
image: postgres:17-alpine
|
|
container_name: polaris-task-force-pg
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-ptfapp}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-polaristaskforcedb}
|
|
POSTGRES_DB: ${POSTGRES_DB:-ptf-app-dev}
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
ports:
|
|
- "${POSTGRES_PORT:-5432}:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-ptfapp} -d ${POSTGRES_DB:-ptf-app-dev}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
start_period: 10s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
pgdata:
|