Files
template_001/docker-compose.yml
SAAC Daemon e349453fbb Document hot-reload workflow for AI agents
Rewrite SAAC_DEPLOYMENT.md to lead with the two-domain model:
- Production (yourapp.<server>.domain.com) — updates on saac deploy
- Hot-reload (yourapp-hot.<server>.domain.com) — auto-rebuilds on git push

Added: recommended dev workflow (push → check hot → deploy to prod),
nodemon.json explanation, development cycle diagram, customization guide.

Updated Dockerfile and docker-compose.yml headers to explain which
container uses which file and reference nodemon.json.
2026-02-18 16:50:06 +01:00

94 lines
2.9 KiB
YAML

# SAAC Application Stack — PRODUCTION container
# See SAAC_DEPLOYMENT.md for full deployment rules and common mistakes.
#
# This file is used by "saac deploy" to build the production Docker image.
# Your app also gets a HOT-RELOAD container (yourapp-hot.<server>.domain.com)
# that auto-rebuilds on every git push — see nodemon.json for its config.
#
# Key rules:
# 1. Use "expose", NEVER "ports" — Traefik handles routing
# 2. Database host = service name ("postgres"), NEVER "localhost"
# 3. Do NOT change POSTGRES_DB after first deploy — Docker volume keeps the old name
# 4. Do NOT add Traefik labels — SAAC uses file provider, labels are ignored
# 5. Keep it simple — get this working first, then iterate
services:
app:
build:
context: .
args:
SOURCE_COMMIT: ${SOURCE_COMMIT:-unknown}
APP_VERSION: ${APP_VERSION:-1.0.0}
restart: unless-stopped
environment:
- NODE_ENV=production
- PORT=3000
# Database host MUST be the service name ("postgres"), not "localhost".
# In Docker, localhost = inside this container. "postgres" resolves to
# the postgres service below via Docker DNS.
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
# WARNING: Do NOT change POSTGRES_DB after first deploy!
# The Docker volume persists the original database name.
# If you change this, the new database won't exist and your app will crash.
- POSTGRES_DB=postgres
- REDIS_HOST=redis
- REDIS_PORT=6379
- APP_VERSION=${APP_VERSION:-1.0.0}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
# Use "expose" to make the port available to Traefik on the Docker network.
# NEVER use "ports" (e.g. "3000:3000") — it binds to the host and conflicts
# with other apps. Traefik handles all external routing automatically.
expose:
- "3000"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 10s
timeout: 3s
start_period: 5s
retries: 2
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
# This creates the database on first start. Must match POSTGRES_DB above.
- POSTGRES_DB=postgres
volumes:
- postgres-data:/var/lib/postgresql/data
expose:
- "5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 3s
retries: 3
redis:
image: redis:7-alpine
restart: unless-stopped
command: redis-server --appendonly yes
volumes:
- redis-data:/data
expose:
- "6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 3
volumes:
postgres-data:
driver: local
redis-data:
driver: local