Files
leocrm/docker-compose.yaml
T
Agent Zero 627360113f fix(permissions): fix 10 high-priority permission system issues
P8: Invalidate all Redis sessions when is_system_admin changes
- Added is_system_admin to UserUpdate schema and UserResponse
- Added invalidate_all_user_sessions call in users.py route
- Added is_system_admin param to user_service.update_user

P9: Remove no-op permission resolution strategies
- Only highest_wins supported, others removed as no-ops
- Updated tenant.py CheckConstraint to only allow highest_wins
- Added KI-Kommentar in permissions.py

P10: Remove legacy check_permission from auth.py
- Removed duplicate check_permission and filter_fields_by_permission
- Fixed ai_copilot_service.py to use permissions.check_permission
- Updated ai_copilot route to pass resolved permissions dict

P11: Verified — no guest_users remnants found

P12: Migrate ContactFolderPermission to EntityPermission
- contact_folder_permission_service now delegates to entity_permission_service
- contact_folder_service uses EntityPermission queries
- Removed ContactFolderPermission from models/__init__.py
- Created migration 0114 to migrate data and drop table

P13: Added RLS migration history comment in alembic/env.py

P14: Verified — services already apply visibility_filter
- saved_filters/views filter by user_id (personal data)
- workspaces are UI context only
- notifications already filter by entity access

P15: Split entity_permission_service.py (932 lines) into 4 modules
- permission_resolver.py: get_effective_access, get_visible_ids, etc.
- permission_cache.py: Redis caching functions
- permission_audit.py: Audit logging helpers
- entity_permission_service.py: CRUD operations + re-exports

P16: Centralize PERM_RANK in permissions.py
- Single source: app.core.permissions.PERM_RANK
- Updated all services to import from permissions.py

P17: Fix MIGRATION_DATABASE_URL to use crm_migration
- docker-compose.yaml defaults changed from crm_user to crm_migration
- .env.docker.example updated
- prestart.sh comment updated
2026-08-06 12:05:09 +02:00

144 lines
5.7 KiB
YAML

# =============================================================================
# docker-compose.yaml — LeoCRM Multi-Container Setup
#
# ⚠️ KI / AGENT HINWEISE — BITTE VOR ÄNDERUNGEN LESEN ⚠️
#
# ARCHITEKTUR: Einzelner docker-compose Stack für Coolify (build_pack=dockercompose)
# Coolify liest diese Datei aus dem Git-Repo und baut alle 4 Container in einem
# gemeinsamen Stack. Alle Container teilen sich ein Docker-Netzwerk.
#
# ❌ NICHT tun:
# - Service-Namen mit Bindestrich (crm-app, crm-worker). Coolify konvertiert
# Bindestriche zu Unterstrichen in docker_compose_domains → kein Match →
# keine Traefik-Labels → 503 Fehler. Verwende Unterstriche: crm_app, crm_worker.
# - Datei als docker-compose.yml (mit .yml) speichern. Coolify sucht .yaml.
# - :443 an Domain anhängen. Das führt zu leeren Host() Traefik-Labels.
# - Eigene networks definieren. Coolify verwaltet das Netzwerk automatisch.
# - container_name setzen. Coolify generiert Container-Namen automatisch.
#
# ✅ RICHTIG:
# - Service-Namen mit Unterstrichen: postgres, redis, crm_app, crm_worker
# - SERVICE_FQDN_CRM_APP_8000 in environment für automatische Domain-Konfiguration
# - depends_on mit condition: service_healthy für korrekte Start-Reihenfolge
# - crm_worker depends_on crm_app (service_healthy) damit prestart.sh zuerst läuft
# und DB-Passwörter setzt bevor der Worker startet
#
# MEHRERE INSTANZEN:
# - APP_NAME und APP_DOMAIN als ENV-Variablen im deploy.py Aufruf setzen
# - Alle anderen Werte werden aus ENV-Variablen gelesen
# =============================================================================
services:
postgres:
image: pgvector/pgvector:pg16
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-crm_user}
POSTGRES_PASSWORD: ${DB_PASSWORD:?DB_PASSWORD is required}
POSTGRES_DB: ${POSTGRES_DB:-crm_db}
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- pgdata:/var/lib/postgresql/data
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
redis:
image: redis:7-alpine
restart: unless-stopped
command: redis-server --requirepass ${REDIS_PASSWORD:?REDIS_PASSWORD is required}
volumes:
- redisdata:/data
healthcheck:
test: ["CMD-SHELL", "redis-cli ping || exit 1"]
interval: 10s
timeout: 5s
retries: 5
crm_app:
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
SERVICE_FQDN_CRM_APP_8000: ${APP_DOMAIN}
DATABASE_URL: ${DATABASE_URL:-postgresql+asyncpg://crm_api:${DB_PASSWORD}@postgres:5432/${POSTGRES_DB:-crm_db}}
AUTH_DATABASE_URL: ${AUTH_DATABASE_URL:-postgresql+asyncpg://crm_auth:${DB_PASSWORD}@postgres:5432/${POSTGRES_DB:-crm_db}}
MIGRATION_DATABASE_URL: ${MIGRATION_DATABASE_URL:-postgresql+asyncpg://crm_migration:${DB_PASSWORD}@postgres:5432/${POSTGRES_DB:-crm_db}}
REDIS_URL: ${REDIS_URL:-redis://default:${REDIS_PASSWORD}@redis:6379/0}
SECRET_KEY: ${SECRET_KEY:?SECRET_KEY is required}
CORS_ORIGINS: ${CORS_ORIGINS}
FRONTEND_URL: ${FRONTEND_URL}
ENVIRONMENT: ${ENVIRONMENT:-production}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
SESSION_COOKIE_SECURE: ${SESSION_COOKIE_SECURE:-true}
STORAGE_PATH: ${STORAGE_PATH:-/data/storage}
SMTP_HOST: ${SMTP_HOST:-}
SMTP_PORT: ${SMTP_PORT:-587}
SMTP_USER: ${SMTP_USER:-}
SMTP_PASSWORD: ${SMTP_PASSWORD:-}
SMTP_FROM: ${SMTP_FROM:-no-reply@localhost}
SMTP_TLS: ${SMTP_TLS:-true}
BCRYPT_ROUNDS: ${BCRYPT_ROUNDS:-12}
ADMIN_EMAIL: ${ADMIN_EMAIL:-admin@media-on.de}
ADMIN_PASSWORD: ${ADMIN_PASSWORD:-Admin123!}
volumes:
- storage:/data/storage
healthcheck:
test: ["CMD", "curl", "-fsS", "http://localhost:8000/api/v1/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
crm_worker:
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
crm_app:
condition: service_healthy
entrypoint: ["/app/worker.sh"]
environment:
DATABASE_URL: ${WORKER_DATABASE_URL:-postgresql+asyncpg://crm_worker:${DB_PASSWORD}@postgres:5432/${POSTGRES_DB:-crm_db}}
WORKER_DATABASE_URL: ${WORKER_DATABASE_URL:-postgresql+asyncpg://crm_worker:${DB_PASSWORD}@postgres:5432/${POSTGRES_DB:-crm_db}}
MIGRATION_DATABASE_URL: ${MIGRATION_DATABASE_URL:-postgresql+asyncpg://crm_migration:${DB_PASSWORD}@postgres:5432/${POSTGRES_DB:-crm_db}}
REDIS_URL: ${REDIS_URL:-redis://default:${REDIS_PASSWORD}@redis:6379/0}
SECRET_KEY: ${SECRET_KEY:?SECRET_KEY is required}
FRONTEND_URL: ${FRONTEND_URL}
ENVIRONMENT: ${ENVIRONMENT:-production}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
SESSION_COOKIE_SECURE: ${SESSION_COOKIE_SECURE:-true}
STORAGE_PATH: ${STORAGE_PATH:-/data/storage}
SMTP_HOST: ${SMTP_HOST:-}
SMTP_PORT: ${SMTP_PORT:-587}
SMTP_USER: ${SMTP_USER:-}
SMTP_PASSWORD: ${SMTP_PASSWORD:-}
SMTP_FROM: ${SMTP_FROM:-no-reply@localhost}
SMTP_TLS: ${SMTP_TLS:-true}
volumes:
- storage:/data/storage
healthcheck:
test: ["CMD-SHELL", "python3 -c \"import redis,os; r=redis.from_url(os.environ.get('REDIS_URL','redis://localhost:6379/0')); print('ok' if r.ping() else 'fail')\" || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
volumes:
pgdata: {}
redisdata: {}
storage: {}