Files
Heimdall/docker/docker-compose.yml
T

262 lines
7.8 KiB
YAML
Raw Normal View History

# ─── Heimdall — Development Docker Compose ─────────────────────────
# Builds image from local source. For production with pre-built images,
# use: docker compose -f docker/docker-compose.prod.yml up -d
# For development with hot-reload, start the required dependencies only and run
# the combined API, Blazor UI and background jobs with `make dev-web`.
#
# The heimdall service serves the Blazor UI, REST API, SignalR hubs,
# and Hangfire background jobs (heartbeat monitor, agent failover)
# in a single process.
x-logging: &default-logging
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
services:
postgresql:
image: postgres:17-alpine
environment:
POSTGRES_DB: ${POSTGRES_DB:-heimdall}
POSTGRES_USER: ${POSTGRES_USER:-heimdall}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
ports:
- "${POSTGRES_PORT:-5432}:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-heimdall}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped
logging: *default-logging
networks:
- heimdall-net
2026-10-21 16:03:16 +02:00
rustfs:
image: rustfs/rustfs:latest
restart: unless-stopped
ports:
2026-10-21 16:03:16 +02:00
- "${RUSTFS_API_PORT:-9000}:9000"
- "${RUSTFS_CONSOLE_PORT:-9001}:9001"
environment:
2026-10-21 16:03:16 +02:00
RUSTFS_VOLUMES: /data
RUSTFS_ADDRESS: 0.0.0.0:9000
RUSTFS_CONSOLE_ADDRESS: 0.0.0.0:9001
RUSTFS_CONSOLE_ENABLE: "true"
RUSTFS_ACCESS_KEY: ${RUSTFS_ACCESS_KEY:?RUSTFS_ACCESS_KEY is required}
RUSTFS_SECRET_KEY: ${RUSTFS_SECRET_KEY:?RUSTFS_SECRET_KEY is required}
volumes:
2026-10-21 16:03:16 +02:00
- rustfs_data:/data
logging: *default-logging
networks:
- heimdall-net
heimdall:
build:
context: ..
dockerfile: docker/Dockerfile
image: heimdall:latest
environment:
# Database
DATABASE_URL: ${DATABASE_URL:?DATABASE_URL is required}
# JWT
JWT__Key: ${JWT__KEY:?JWT__KEY is required}
JWT__RefreshKey: ${JWT__REFRESHKEY:?JWT__REFRESHKEY is required}
JWT__Issuer: ${JWT__ISSUER:-heimdall}
JWT__Audience: ${JWT__AUDIENCE:-heimdall-api}
# ASP.NET
ASPNETCORE_ENVIRONMENT: ${ASPNETCORE_ENVIRONMENT:-Production}
ASPNETCORE_URLS: http://+:8080
# CORS (for external agents and API clients)
Cors__AllowedOrigins: ${Cors__AllowedOrigins:-*}
# Ollama (optional — daily summaries)
Ollama__Endpoint: http://ollama:11434
# Coturn (WebRTC relay)
Coturn__Url: turns:coturn:3478
# Redis (SignalR backplane, optional — scaling)
ConnectionStrings__Redis: redis:6379
# Error tracking
ports:
- "${WEB_PORT:-5000}:8080"
depends_on:
postgresql:
condition: service_healthy
volumes:
- heimdall_data:/var/lib/heimdall
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
restart: unless-stopped
logging: *default-logging
networks:
- heimdall-net
ntfy:
image: binwiederhier/ntfy
container_name: heimdall-ntfy
restart: unless-stopped
command:
- "serve"
environment:
- TZ=Europe/Paris
volumes:
- ntfy_data:/var/lib/ntfy
ports:
- "8080:80"
networks:
- heimdall-net
heimdall-agent:
2026-10-22 07:00:12 +02:00
image: heimdall-agent:latest
build:
context: ..
dockerfile: docker/Dockerfile.agent
args:
# Select GPU runtime: nvidia | amd | intel | cpu (default)
TARGET_RUNTIME: ${AGENT_RUNTIME:-cpu}
# Host network: the agent must see the real camera LAN to run discovery.
# On a bridge network it only sees 172.x → the scanner skips (no local subnet).
network_mode: host
environment:
# Diagnostics are loopback-only; 8081 avoids conflicts with ntfy.
ASPNETCORE_URLS: http://127.0.0.1:8081
# Host network: Docker DNS names don't resolve → reach the Central via
# a host-reachable URL (same machine: http://localhost:5010)
Agent__CentralUrl: ${HEIMDALL_CENTRAL_URL:-http://localhost:5010}
# This development profile uses local plain HTTP; never enable this in production.
Agent__AllowInsecureHttp: "true"
Agent__SiteToken: ${HEIMDALL_SITE_TOKEN:?HEIMDALL_SITE_TOKEN is required}
Agent__AgentName: ${HEIMDALL_AGENT_NAME:-agent-01}
Agent__HeartbeatIntervalSeconds: ${HEIMDALL_HEARTBEAT_INTERVAL:-30}
Agent__StateDirectory: /var/lib/heimdall
Agent__RegistrationMaxRetries: ${HEIMDALL_REGISTRATION_RETRIES:-5}
# ONNX Runtime GPU provider selection
ORT_PROVIDER: ${AGENT_ORT_PROVIDER:-CUDA}
ORT_CUDA_DEVICE_ID: ${AGENT_CUDA_DEVICE_ID:-0}
volumes:
- agent_state:/var/lib/heimdall
2026-10-22 07:00:12 +02:00
user: "1654:1654"
# GPU device exposure (NVIDIA CUDA, AMD ROCm, Intel VAAPI/iGPU)
# Override in docker-compose.local.yml for specific GPU hardware:
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: 1
# capabilities: [gpu]
# Or for AMD ROCm:
# devices:
# - /dev/kfd:/dev/kfd
# - /dev/dri:/dev/dri
# Or for Intel iGPU/VAAPI:
# devices:
# - /dev/dri:/dev/dri
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:8081/healthz"]
interval: 30s
timeout: 5s
retries: 3
start_period: 15s
depends_on:
2026-10-22 07:00:12 +02:00
heimdall:
condition: service_started
agent-state-init:
condition: service_completed_successfully
restart: unless-stopped
logging: *default-logging
# no networks: host networking
2026-10-22 07:00:12 +02:00
# Migrate existing root-owned state before starting the non-root agent.
agent-state-init:
image: heimdall-agent:latest
user: "0:0"
entrypoint: ["chown", "-R", "1654:1654", "/state"]
volumes:
- agent_state:/state
restart: "no"
# ── Optional services (dev) ────────────────────────────────────
coturn:
image: coturn/coturn:4.6
command: >
-n --use-auth-secret
--static-auth-secret=${COTURN_SECRET:?COTURN_SECRET is required}
--realm=${COTURN_REALM:-heimdall.local}
--fingerprint
--no-tlsv1
--no-tlsv1_1
--log-file=stdout
network_mode: host
restart: unless-stopped
logging: *default-logging
ollama:
image: ollama/ollama:latest
restart: unless-stopped
ports:
- "${OLLAMA_PORT:-11434}:11434"
volumes:
- ollama_data:/root/.ollama
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:11434/api/tags"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
logging: *default-logging
networks:
- heimdall-net
redis:
image: redis:7-alpine
command: redis-server --appendonly yes
ports:
- "${REDIS_PORT:-6379}:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
restart: unless-stopped
logging: *default-logging
networks:
- heimdall-net
volumes:
pgdata:
driver: local
2026-10-21 16:03:16 +02:00
rustfs_data:
driver: local
agent_state:
driver: local
heimdall_data:
driver: local
ntfy_data:
driver: local
ollama_data:
driver: local
redis_data:
driver: local
networks:
heimdall-net:
driver: bridge