Files
leocrm/docker-compose.yml
T
Agent Zero 727d86614e Security fixes: P0-P2 complete (22 fixes)
P0 (7): Auth-bypass removed, migrations fixed, plugin-upload disabled, RLS FORCE+WITH CHECK, plugin double-registration fixed, persistent volume, domain removed
P1 (11): User/tenant model, Redis centralized, worker separated, transactional outbox, XSS fixed, DMS chunked streaming, permissions unified, password reset, metrics secured, config/docs fixed, cross-tenant FK
P2 (4): Contact model normalized, cross-imports reduced 94%, commands+state machines for contacts/dms/mail/calendar, SPA path-traversal

8 new migrations, 99 unit tests, 13 commands, 8 contracts, 72 files changed
2026-07-25 21:03:46 +02:00

155 lines
5.5 KiB
YAML

# =============================================================================
# docker-compose.yml — CRM System v1.0 (local testing with PostgreSQL)
#
# Use this file to run a full Postgres + crm-app stack locally, e.g. for
# smoke-testing the Docker image or running the backend against a real
# PostgreSQL instance before deploying to Coolify.
#
# Production deploys in Coolify use COOLIFY_SETUP.md (single-container app +
# a Coolify-managed Postgres database), NOT this file.
#
# Usage:
# cp .env.docker.example .env.docker
# $EDITOR .env.docker # fill AUTH_SECRET, POSTGRES_PASSWORD, ...
# docker compose --env-file .env.docker up --build
# curl http://localhost:8000/health
# =============================================================================
services:
# -------------------------------------------------------------------------
# PostgreSQL 16 (Alpine) — local Postgres for development / smoke tests.
# Coolify will provision its own managed Postgres database in production.
# -------------------------------------------------------------------------
postgres:
image: postgres:16-alpine
container_name: crm-postgres
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-crm_user}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
POSTGRES_DB: ${POSTGRES_DB:-crm_db}
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- "5432:5432" # local-only convenience; remove for CI / prod-like runs
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-crm_user} -d ${POSTGRES_DB:-crm_db}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
- crm-net
# -------------------------------------------------------------------------
# CRM App — built from the local Dockerfile.
# NOTE: no `image:` directive — we build from source on `docker compose up`.
# -------------------------------------------------------------------------
crm-app:
build:
context: .
dockerfile: Dockerfile
container_name: crm-app
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
# Use the internal docker-compose DNS name "postgres" (NOT localhost)
DATABASE_URL: ${DATABASE_URL:?DATABASE_URL is required}
REDIS_URL: ${REDIS_URL:-redis://:${REDIS_PASSWORD:-changeme}@redis:6379/0}
SECRET_KEY: ${SECRET_KEY:?SECRET_KEY is required (min 32 chars)}
# Frontend served from same origin in production; allow local dev hosts too
CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:8000,http://localhost:5173}
ENVIRONMENT: ${ENVIRONMENT:-production}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
SESSION_COOKIE_SECURE: ${SESSION_COOKIE_SECURE:-true}
STORAGE_PATH: ${STORAGE_PATH:-/data/storage}
BCRYPT_ROUNDS: ${BCRYPT_ROUNDS:-12}
ports:
- "8000:8000"
volumes:
- storage:/data/storage
healthcheck:
test: ["CMD", "curl", "-fsS", "http://localhost:8000/api/v1/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 15s
networks:
- crm-net
# -------------------------------------------------------------------------
# CRM Worker — ARQ background worker (same image, different entrypoint).
# Runs migrations? No — the API container handles migrations.
# Scale with `docker compose up --scale crm-worker=N`.
# Cron jobs use a Redis-based distributed lock so only one replica fires.
# -------------------------------------------------------------------------
crm-worker:
build:
context: .
dockerfile: Dockerfile
container_name: crm-worker
restart: unless-stopped
entrypoint: ["/app/worker.sh"]
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
DATABASE_URL: ${DATABASE_URL:?DATABASE_URL is required}
REDIS_URL: ${REDIS_URL:-redis://:${REDIS_PASSWORD:-changeme}@redis:6379/0}
SECRET_KEY: ${SECRET_KEY:?SECRET_KEY is required (min 32 chars)}
ENVIRONMENT: ${ENVIRONMENT:-production}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
STORAGE_PATH: ${STORAGE_PATH:-/data/storage}
BCRYPT_ROUNDS: ${BCRYPT_ROUNDS:-12}
volumes:
- storage:/data/storage
healthcheck:
# Check if the ARQ worker process is alive
test: ["CMD-SHELL", "pgrep -f \"arq app.core.worker.WorkerSettings\" || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 15s
networks:
- crm-net
# -------------------------------------------------------------------------
# Redis 7 (Alpine) — sessions, rate limiting, ARQ queue.
# -------------------------------------------------------------------------
redis:
image: redis:7-alpine
container_name: crm-redis
restart: unless-stopped
command: redis-server --requirepass ${REDIS_PASSWORD:-changeme}
volumes:
- redisdata:/data
ports:
- "6379:6379" # local-only convenience; remove for prod-like runs
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-changeme}", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- crm-net
volumes:
pgdata:
name: crm_pgdata
redisdata:
name: crm_redisdata
storage:
name: crm_storage
networks:
crm-net:
name: crm-net
driver: bridge