refactor(docker): separate core and optional compose services
Heimdall Gitea / Detect CI scope (pull_request) Successful in 5s
Heimdall Gitea / Build and tests (pull_request) Successful in 13m35s
Heimdall Gitea / Publish versioned release (pull_request) Skipped
Heimdall Gitea / Build and scan agent image (pull_request) Successful in 6m28s
Heimdall Gitea / Build and scan server image (pull_request) Successful in 8m24s
Heimdall Gitea / Publish Docker Hub latest tags (pull_request) Skipped
Heimdall Gitea / CI policy (pull_request) Successful in 3s

This commit is contained in:
Arnaud Dartois committed 2026-10-26 05:59:55 +01:00
1 parent 25dc4869d2
commit 88033e8e26
25 files changed
+507 -714

No files matched your search

+7 -14
View File
@@ -12,24 +12,17 @@ Sauvegarde automatisée de PostgreSQL (quotidien) et RustFS/S3 (hebdomadaire) av
## Activation
### Option 1 — Overlay docker-compose (recommandé)
### Compose facultatif séparé
```bash
cd docker/
docker compose -f docker-compose.yml -f docker-compose.backup.yml up -d
docker compose --env-file .env -f docker-compose.backup.yml up -d
```
Le service `backup` tourne dans un conteneur PostgreSQL 17-alpine avec crontab interne.
Les dumps sont stockés dans le volume `backup_data` et uploadés vers RustFS/S3 si configuré.
### Option 2 — Profil dans docker-compose.prod.yml
```bash
cd docker/
docker compose --profile backup -f docker-compose.prod.yml up -d
```
Le service backup est activé via le profil Docker Compose `backup`.
Le Central et PostgreSQL doivent d'abord être démarrés. Le service `backup`
rejoint le réseau partagé et tourne dans un conteneur PostgreSQL 17-alpine
avec crontab interne. Les dumps sont stockés dans `backup_data`; l'upload
RustFS/S3 est facultatif.
## Variables d'environnement
@@ -39,7 +32,7 @@ Le service backup est activé via le profil Docker Compose `backup`.
| `POSTGRES_PORT` | `5432` | Port PostgreSQL |
| `POSTGRES_DB` | `heimdall` | Nom de la base |
| `POSTGRES_USER` | `heimdall` | Utilisateur PostgreSQL |
| `POSTGRES_PASSWORD` | `heimdall` | Mot de passe PostgreSQL |
| `docker/secrets/db_password` | fichier hôte requis | Mot de passe PostgreSQL partagé avec le Compose Central |
| `RUSTFS_ENDPOINT` | `http://rustfs:9000` (Compose) | Endpoint S3/RustFS |
| `RUSTFS_ACCESS_KEY` | — | Clé d'accès S3 |
| `RUSTFS_SECRET_KEY` | — | Clé secrète S3 |
+43
View File
@@ -0,0 +1,43 @@
# Local standalone Agent for development. The Central must be running first.
services:
heimdall-agent:
image: heimdall-agent:local
build:
context: ..
dockerfile: docker/Dockerfile.agent
restart: unless-stopped
user: "1654:1654"
network_mode: host
environment:
ASPNETCORE_URLS: http://127.0.0.1:8081
Agent__CentralUrl: ${HEIMDALL_CENTRAL_URL:-http://localhost:5000}
Agent__AllowInsecureHttp: "true"
Agent__SiteToken: ${HEIMDALL_SITE_TOKEN:?HEIMDALL_SITE_TOKEN is required}
Agent__AgentName: ${HEIMDALL_AGENT_NAME:-agent-dev}
Agent__HeartbeatIntervalSeconds: ${HEIMDALL_HEARTBEAT_INTERVAL:-30}
Agent__StateDirectory: /var/lib/heimdall
volumes:
- agent_state:/var/lib/heimdall
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:
agent-state-init:
condition: service_completed_successfully
agent-state-init:
image: heimdall-agent:local
build:
context: ..
dockerfile: docker/Dockerfile.agent
user: "0:0"
entrypoint: ["chown", "-R", "1654:1654", "/state"]
volumes:
- agent_state:/state
restart: "no"
volumes:
agent_state:
+51
View File
@@ -0,0 +1,51 @@
# Standalone production Agent. Copy this file and the release public key to the
# camera host, or use the digest-pinned Compose supplied by the Central UI.
# Usage: docker compose --env-file .env -f docker-compose.agent.yml up -d
services:
heimdall-agent:
image: ${AGENT_IMAGE_REFERENCE:?Set AGENT_IMAGE_REFERENCE from the Central image manifest}
restart: unless-stopped
user: "1654:1654"
network_mode: host
environment:
ASPNETCORE_URLS: http://127.0.0.1:8081
Agent__CentralUrl: ${HEIMDALL_CENTRAL_URL:?HEIMDALL_CENTRAL_URL is required}
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__UpdatePublicKeyPath: /run/secrets/agent-release-public.pem
volumes:
- agent_state:/var/lib/heimdall
- type: bind
source: ./secrets/agent-release-public.pem
target: /run/secrets/agent-release-public.pem
read_only: true
bind:
create_host_path: false
depends_on:
agent-state-init:
condition: service_completed_successfully
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
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
agent-state-init:
image: ${AGENT_IMAGE_REFERENCE:?Set AGENT_IMAGE_REFERENCE from the Central image manifest}
user: "0:0"
entrypoint: ["chown", "-R", "1654:1654", "/state"]
volumes:
- agent_state:/state
restart: "no"
volumes:
agent_state:
+23 -42
View File
@@ -1,70 +1,51 @@
# ─── Heimdall — Backup Cron Service ──────────────────────────────
# Overlay for docker-compose.yml: adds a cron container that runs
# PostgreSQL backups daily and RustFS mirrors weekly.
#
# Usage:
# docker compose -f docker/docker-compose.yml -f docker/docker-compose.backup.yml up -d
#
# The cron service mounts the scripts directory and a backup volume.
# PostgreSQL dumps are uploaded to RustFS/S3 when configured.
#
# Requires: .env with DATABASE_URL, S3 credentials (optional for local-only backups)
# ──────────────────────────────────────────────────────────────────
# Optional scheduled backup container. Requires the core PostgreSQL service
# and its shared heimdall-net to be running first.
services:
backup:
image: postgres:17-alpine
container_name: heimdall-backup
restart: unless-stopped
environment:
# Pass through all env vars needed by backup scripts
POSTGRES_HOST: postgresql
POSTGRES_PORT: "5432"
POSTGRES_DB: ${POSTGRES_DB:-heimdall}
POSTGRES_USER: ${POSTGRES_USER:-heimdall}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
# S3/RustFS config (optional — backup works local-only without these)
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
RUSTFS_ENDPOINT: ${RUSTFS_ENDPOINT:-http://rustfs:9000}
RUSTFS_ACCESS_KEY: ${RUSTFS_ACCESS_KEY:-${S3_ACCESS_KEY:-}}
RUSTFS_SECRET_KEY: ${RUSTFS_SECRET_KEY:-${S3_SECRET_KEY:-}}
RUSTFS_BUCKET: ${RUSTFS_BUCKET:-${S3_BUCKET:-heimdall}}
# Backup config
RUSTFS_ACCESS_KEY: ${RUSTFS_ACCESS_KEY:-}
RUSTFS_SECRET_KEY: ${RUSTFS_SECRET_KEY:-}
RUSTFS_BUCKET: ${RUSTFS_BUCKET:-heimdall}
BACKUP_RETENTION_DAYS: ${BACKUP_RETENTION_DAYS:-30}
BACKUP_RETENTION_WEEKS: ${BACKUP_RETENTION_WEEKS:-12}
BACKUP_LOCAL_DIR: /backups
# Timezone
TZ: Europe/Paris
TZ: ${TZ:-Europe/Paris}
secrets:
- db_password
volumes:
- ./scripts:/scripts:ro
- backup_data:/backups
depends_on:
postgresql:
condition: service_healthy
networks:
- heimdall-net
entrypoint: ["/bin/sh", "-c"]
command:
- |
# Install mc (MinIO client) for S3 uploads
apk add --no-cache curl bash > /dev/null 2>&1 || true
curl -sSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc 2>/dev/null || true
export POSTGRES_PASSWORD="$$(cat /run/secrets/db_password)"
apk add --no-cache curl bash >/dev/null 2>&1 || true
curl -fsSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc || true
chmod +x /usr/local/bin/mc 2>/dev/null || true
chmod +x /scripts/*.sh
# Create crontab
echo "# Daily PostgreSQL backup at 02:00 UTC" > /tmp/crontab.txt
echo "0 2 * * * /scripts/backup.sh >> /var/log/backup.log 2>&1" >> /tmp/crontab.txt
echo "# Weekly RustFS mirror on Sundays at 03:00 UTC" >> /tmp/crontab.txt
echo "0 3 * * 0 /scripts/backup-rustfs.sh >> /var/log/backup-rustfs.log 2>&1" >> /tmp/crontab.txt
echo "# Log rotation weekly" >> /tmp/crontab.txt
echo "0 4 * * 0 if [ -f /var/log/backup.log ]; then mv /var/log/backup.log /var/log/backup.log.\$$(date +\%Y\%W); fi" >> /tmp/crontab.txt
echo '0 2 * * * /scripts/backup.sh >> /var/log/backup.log 2>&1' > /tmp/crontab.txt
echo '0 3 * * 0 /scripts/backup-rustfs.sh >> /var/log/backup-rustfs.log 2>&1' >> /tmp/crontab.txt
crontab /tmp/crontab.txt
echo "Crontab installed:"
crontab -l
# Run crond in foreground
exec crond -f -l 2
volumes:
backup_data:
driver: local
secrets:
db_password:
file: ./secrets/db_password
networks:
heimdall-net:
name: heimdall-net
external: true
+17
View File
@@ -0,0 +1,17 @@
# Optional TURN relay, used only by a future/externally integrated WebRTC setup.
services:
coturn:
image: coturn/coturn:4.6
command: >
-n --use-auth-secret
--static-auth-secret-file=/run/secrets/coturn_secret
--realm=${COTURN_REALM:-heimdall.local}
--fingerprint --no-tlsv1 --no-tlsv1_1 --log-file=stdout
network_mode: host
secrets:
- coturn_secret
restart: unless-stopped
secrets:
coturn_secret:
file: ./secrets/coturn_secret
-18
View File
@@ -1,18 +0,0 @@
# ─── Heimdall — Override: use locally-built image with current fixes ───
# Use locally-built images rather than the production release images.
# Usage: AGENT_IMAGE_REFERENCE=heimdall-agent:local docker compose --env-file docker/.env -f docker/docker-compose.prod.yml -f docker/docker-compose.local.yml up -d
services:
heimdall:
image: heimdall:local
build:
context: ..
dockerfile: docker/Dockerfile
heimdall-agent:
image: heimdall-agent:local
build:
context: ..
dockerfile: docker/Dockerfile.agent
agent-state-init:
image: heimdall-agent:local
+23
View File
@@ -0,0 +1,23 @@
# Optional self-hosted ntfy service. Central's default URL is http://ntfy:80.
services:
ntfy:
image: binwiederhier/ntfy:latest
restart: unless-stopped
command: ["serve"]
environment:
TZ: ${TZ:-Europe/Paris}
NTFY_AUTH_FILE: /var/lib/ntfy/auth
ports:
- "${NTFY_PORT:-8080}:80"
volumes:
- ntfy_data:/var/lib/ntfy
networks:
- heimdall-net
volumes:
ntfy_data:
networks:
heimdall-net:
name: heimdall-net
external: true
+25
View File
@@ -0,0 +1,25 @@
# Optional local Ollama backend. Set OLLAMA_URL=http://ollama:11434 on Central.
services:
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
networks:
- heimdall-net
volumes:
ollama_data:
networks:
heimdall-net:
name: heimdall-net
external: true
+20 -295
View File
@@ -1,31 +1,11 @@
# ─── Heimdall — Production Docker Compose ─────────────────────────
# Pulls pre-built images from Docker Hub instead of building locally.
# Usage: docker compose -f docker/docker-compose.prod.yml up -d
# Prerequisite: cp .env.example .env && edit secrets
#
# Secrets are stored in docker/secrets/ (gitignored). Create them with:
# mkdir -p docker/secrets
# openssl rand -base64 32 > docker/secrets/jwt_signing_key
# openssl rand -base64 32 > docker/secrets/jwt_refresh_key
# openssl rand -base64 32 > docker/secrets/coturn_secret
# echo -n "your-db-password" > docker/secrets/db_password
# openssl rand -hex 12 > docker/secrets/rustfs_access_key
# openssl rand -base64 32 > docker/secrets/rustfs_secret_key
# echo -n "your-smtp-password" > docker/secrets/smtp_password
# cp /path/from/trusted-release-channel/agent-release-public.pem docker/secrets/agent-release-public.pem
# chmod 644 docker/secrets/agent-release-public.pem
#
# Set SERVER_IMAGE_REFERENCE to the server image selected for this deployment.
# Its repository is configured in docker/server-image.json.
#
# The heimdall service serves the Blazor UI, REST API, SignalR hubs,
# and Hangfire background jobs (heartbeat monitor, agent failover)
# in a single process.
# Production core: PostgreSQL and Heimdall Central only.
# Usage: docker compose --env-file docker/.env -f docker/docker-compose.prod.yml up -d
# Optional software has its own Compose file; see docs/docker-compose.md.
x-logging: &default-logging
driver: "json-file"
driver: json-file
options:
max-size: "10m"
max-size: 10m
max-file: "3"
services:
@@ -52,59 +32,34 @@ services:
networks:
- heimdall-net
rustfs:
image: rustfs/rustfs:latest
restart: unless-stopped
ports:
- "${RUSTFS_API_PORT:-9000}:9000"
- "${RUSTFS_CONSOLE_PORT:-9001}:9001"
environment:
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_FILE: /run/secrets/rustfs_access_key
RUSTFS_SECRET_KEY_FILE: /run/secrets/rustfs_secret_key
secrets:
- rustfs_access_key
- rustfs_secret_key
volumes:
- rustfs_data:/data
logging: *default-logging
networks:
- heimdall-net
heimdall:
image: ${SERVER_IMAGE_REFERENCE:?Set SERVER_IMAGE_REFERENCE from docker/server-image.json}
environment:
# Database (password from secret, rest from env)
DATABASE_URL: ${DATABASE_URL:?DATABASE_URL is required}
# JWT (keys from secrets)
JWT__Issuer: ${JWT__ISSUER:-heimdall}
JWT__Audience: ${JWT__AUDIENCE:-heimdall-api}
# ASP.NET
JWT__KEY: ${JWT__KEY:?JWT__KEY is required}
JWT__REFRESHKEY: ${JWT__REFRESHKEY:?JWT__REFRESHKEY is required}
ASPNETCORE_ENVIRONMENT: ${ASPNETCORE_ENVIRONMENT:-Production}
ASPNETCORE_URLS: http://+:8080
# CORS (for external agents and API clients)
Cors__AllowedOrigins: ${Cors__AllowedOrigins:-*}
# Monolith: internal HTTP calls (circuit-triggered) must target the
# container's own listener, NOT the host-mapped origin the browser sees.
API_BASE_URL: ${API_BASE_URL:-http://localhost:8080}
# Central selects the release source; agents obtain the image and digest from Central.
Updates__ReleaseApiUrl: ${UPDATES_RELEASE_API_URL:?Set the Central release API URL}
# 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
# Sentry / GlitchTip (error tracking)
Sentry__Dsn: ${SENTRY_DSN:-}
Sentry__TracesSampleRate: ${SENTRY_TRACES_SAMPLE_RATE:-0.05}
Sentry__Release: ${SENTRY_RELEASE:-}
secrets:
- jwt_signing_key
- jwt_refresh_key
EMAIL__SMTP_HOST: ${EMAIL__SMTP_HOST:-}
EMAIL__SMTP_PORT: ${EMAIL__SMTP_PORT:-587}
EMAIL__USERNAME: ${EMAIL__USERNAME:-}
EMAIL__PASSWORD: ${EMAIL__PASSWORD:-}
EMAIL__FROM_ADDRESS: ${EMAIL__FROM_ADDRESS:-noreply@heimdall.local}
EMAIL__FROM_NAME: ${EMAIL__FROM_NAME:-Heimdall}
EMAIL__USE_SSL: ${EMAIL__USE_SSL:-true}
# Optional integrations are configured only when their service is deployed.
OLLAMA_URL: ${OLLAMA_URL:-}
NTFY__BASE_URL: ${NTFY__BASE_URL:-http://ntfy:80}
NTFY__TOKEN: ${NTFY__TOKEN:-}
STORAGE__PROVIDER: ${STORAGE__PROVIDER:-Local}
ports:
- "${WEB_PORT:-5000}:8080"
volumes:
@@ -113,8 +68,6 @@ services:
depends_on:
postgresql:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
interval: 30s
@@ -126,244 +79,16 @@ services:
networks:
- heimdall-net
ntfy:
image: binwiederhier/ntfy:latest
container_name: heimdall-ntfy
restart: unless-stopped
command:
- "serve"
environment:
- TZ=Europe/Paris
- NTFY_AUTH_FILE=/var/lib/ntfy/auth
volumes:
- ntfy_data:/var/lib/ntfy
networks:
- heimdall-net
heimdall-agent:
# Pin the exact image reference supplied by the Central release manifest.
image: ${AGENT_IMAGE_REFERENCE:?Set AGENT_IMAGE_REFERENCE from the Central agent image manifest}
# 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 → point HEIMDALL_CENTRAL_URL
# to the Central's public URL (e.g. https://heimdall.tordais.cc)
Agent__CentralUrl: ${HEIMDALL_CENTRAL_URL:?HEIMDALL_CENTRAL_URL is required (public URL of the Central, e.g. https://heimdall.tordais.cc)}
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__UpdatePublicKeyPath: /run/secrets/agent-release-public.pem
# The published Agent image runs ONNX inference on CPU. Optional GPU
# passthrough overlays are only for device inventory/experimentation.
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
volumes:
- agent_state:/var/lib/heimdall
- type: bind
source: ./secrets/agent-release-public.pem
target: /run/secrets/agent-release-public.pem
read_only: true
bind:
create_host_path: false
user: "1654:1654"
depends_on:
heimdall:
condition: service_started
agent-state-init:
condition: service_completed_successfully
restart: unless-stopped
logging: *default-logging
# no networks: host networking
# Migrate existing root-owned state before starting the non-root agent.
agent-state-init:
image: ${AGENT_IMAGE_REFERENCE:?Set AGENT_IMAGE_REFERENCE from the Central agent image manifest}
user: "0:0"
entrypoint: ["chown", "-R", "1654:1654", "/state"]
volumes:
- agent_state:/state
restart: "no"
# ── Backup service (opt-in via --profile backup) ───────────────
backup:
image: postgres:17-alpine
container_name: heimdall-backup
profiles:
- backup
environment:
POSTGRES_HOST: postgresql
POSTGRES_PORT: "5432"
POSTGRES_DB: ${POSTGRES_DB:-heimdall}
POSTGRES_USER: ${POSTGRES_USER:-heimdall}
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
# S3/RustFS config (optional — backup works local-only without these)
RUSTFS_ENDPOINT: ${RUSTFS_ENDPOINT:-http://rustfs:9000}
RUSTFS_ACCESS_KEY: ${RUSTFS_ACCESS_KEY:-}
RUSTFS_SECRET_KEY: ${RUSTFS_SECRET_KEY:-}
RUSTFS_BUCKET: ${RUSTFS_BUCKET:-heimdall}
# Backup config
BACKUP_RETENTION_DAYS: ${BACKUP_RETENTION_DAYS:-30}
BACKUP_RETENTION_WEEKS: ${BACKUP_RETENTION_WEEKS:-12}
BACKUP_LOCAL_DIR: /backups
TZ: Europe/Paris
secrets:
- db_password
- rustfs_access_key
- rustfs_secret_key
volumes:
- ./scripts:/scripts:ro
- backup_data:/backups
depends_on:
postgresql:
condition: service_healthy
networks:
- heimdall-net
restart: unless-stopped
logging: *default-logging
entrypoint: ["/bin/sh", "-c"]
command:
- |
# Read password from Docker secret file
if [ -f /run/secrets/db_password ]; then
export POSTGRES_PASSWORD="$(cat /run/secrets/db_password)"
fi
if [ -f /run/secrets/rustfs_access_key ]; then
export RUSTFS_ACCESS_KEY="$(cat /run/secrets/rustfs_access_key)"
fi
if [ -f /run/secrets/rustfs_secret_key ]; then
export RUSTFS_SECRET_KEY="$(cat /run/secrets/rustfs_secret_key)"
fi
apk add --no-cache curl bash > /dev/null 2>&1 || true
curl -sSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc 2>/dev/null || true
chmod +x /usr/local/bin/mc 2>/dev/null || true
chmod +x /scripts/*.sh
# Create crontab
echo "# Daily PostgreSQL backup at 02:00 UTC" > /tmp/crontab.txt
echo "0 2 * * * /scripts/backup.sh >> /var/log/backup.log 2>&1" >> /tmp/crontab.txt
echo "# Weekly RustFS mirror on Sundays at 03:00 UTC" >> /tmp/crontab.txt
echo "0 3 * * 0 /scripts/backup-rustfs.sh >> /var/log/backup-rustfs.log 2>&1" >> /tmp/crontab.txt
echo "# Log rotation weekly" >> /tmp/crontab.txt
echo "0 4 * * 0 if [ -f /var/log/backup.log ]; then mv /var/log/backup.log /var/log/backup.log.\$$(date +\%Y\%W); fi" >> /tmp/crontab.txt
crontab /tmp/crontab.txt
echo "Crontab installed:"
crontab -l
# Run crond in foreground
exec crond -f -l 2
# ── Optional services ──────────────────────────────────────────
coturn:
image: coturn/coturn:4.6
# TURN relay for WebRTC — network_mode host required for UDP ports.
command: >
-n --use-auth-secret
--static-auth-secret-file=/run/secrets/coturn_secret
--realm=${COTURN_REALM:-heimdall.local}
--fingerprint
--no-tlsv1
--no-tlsv1_1
--log-file=stdout
network_mode: host
secrets:
- coturn_secret
restart: unless-stopped
logging: *default-logging
ollama:
image: ollama/ollama:latest
# Local LLM for daily summaries and event analysis.
# GPU passthrough: add --gpus all or mount /dev/dri for Intel/AMD.
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
# Uncomment for GPU passthrough:
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: all
# capabilities: [gpu]
redis:
image: redis:7-alpine
# SignalR backplane (scaling) + cache.
command: redis-server --requirepass ${REDIS_PASSWORD:-} --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
rustfs_data:
driver: local
agent_state:
driver: local
heimdall_data:
driver: local
ntfy_data:
driver: local
dataprotection_keys:
driver: local
ollama_data:
driver: local
redis_data:
driver: local
backup_data:
driver: local
secrets:
db_password:
file: ./secrets/db_password
jwt_signing_key:
file: ./secrets/jwt_signing_key
jwt_refresh_key:
file: ./secrets/jwt_refresh_key
coturn_secret:
file: ./secrets/coturn_secret
rustfs_access_key:
file: ./secrets/rustfs_access_key
rustfs_secret_key:
file: ./secrets/rustfs_secret_key
smtp_password:
file: ./secrets/smtp_password
networks:
heimdall-net:
name: heimdall-net
driver: bridge
+26
View File
@@ -0,0 +1,26 @@
# Optional standalone Redis service. Heimdall currently does not require it.
services:
redis:
image: redis:7-alpine
command: ["redis-server", "--appendonly", "yes", "--requirepass", "${REDIS_PASSWORD:?Set REDIS_PASSWORD}"]
environment:
REDISCLI_AUTH: ${REDIS_PASSWORD:?Set REDIS_PASSWORD}
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
restart: unless-stopped
networks:
- heimdall-net
volumes:
redis_data:
networks:
heimdall-net:
name: heimdall-net
external: true
+39
View File
@@ -0,0 +1,39 @@
# Optional S3-compatible object store. Start the core Compose first so the
# shared heimdall-net exists, then configure storage in Central to use rustfs.
services:
rustfs:
image: rustfs/rustfs:latest
restart: unless-stopped
ports:
- "${RUSTFS_API_PORT:-9000}:9000"
- "${RUSTFS_CONSOLE_PORT:-9001}:9001"
environment:
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_FILE: /run/secrets/rustfs_access_key
RUSTFS_SECRET_KEY_FILE: /run/secrets/rustfs_secret_key
secrets:
- rustfs_access_key
- rustfs_secret_key
volumes:
- rustfs_data:/data
networks:
heimdall-net:
aliases:
- rustfs
volumes:
rustfs_data:
secrets:
rustfs_access_key:
file: ./secrets/rustfs_access_key
rustfs_secret_key:
file: ./secrets/rustfs_secret_key
networks:
heimdall-net:
name: heimdall-net
external: true
+22 -181
View File
@@ -1,18 +1,5 @@
# ─── 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"
# Local development core: PostgreSQL and Heimdall Central only.
# The Agent and optional software have separate Compose files.
services:
postgresql:
@@ -32,26 +19,6 @@ services:
retries: 5
start_period: 30s
restart: unless-stopped
logging: *default-logging
networks:
- heimdall-net
rustfs:
image: rustfs/rustfs:latest
restart: unless-stopped
ports:
- "${RUSTFS_API_PORT:-9000}:9000"
- "${RUSTFS_CONSOLE_PORT:-9001}:9001"
environment:
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:
- rustfs_data:/data
logging: *default-logging
networks:
- heimdall-net
@@ -59,34 +26,34 @@ services:
build:
context: ..
dockerfile: docker/Dockerfile
image: heimdall:latest
image: heimdall:local
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}
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}
ASPNETCORE_ENVIRONMENT: ${ASPNETCORE_ENVIRONMENT:-Development}
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
API_BASE_URL: ${API_BASE_URL:-http://localhost:8080}
OLLAMA_URL: ${OLLAMA_URL:-}
NTFY__BASE_URL: ${NTFY__BASE_URL:-http://ntfy:80}
NTFY__TOKEN: ${NTFY__TOKEN:-}
EMAIL__SMTP_HOST: ${EMAIL__SMTP_HOST:-}
EMAIL__SMTP_PORT: ${EMAIL__SMTP_PORT:-587}
EMAIL__USERNAME: ${EMAIL__USERNAME:-}
EMAIL__PASSWORD: ${EMAIL__PASSWORD:-}
EMAIL__FROM_ADDRESS: ${EMAIL__FROM_ADDRESS:-noreply@heimdall.local}
EMAIL__FROM_NAME: ${EMAIL__FROM_NAME:-Heimdall}
EMAIL__USE_SSL: ${EMAIL__USE_SSL:-true}
ports:
- "${WEB_PORT:-5000}:8080"
volumes:
- heimdall_data:/var/lib/heimdall
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
@@ -94,140 +61,14 @@ services:
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:
image: heimdall-agent:latest
build:
context: ..
dockerfile: docker/Dockerfile.agent
# 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}
volumes:
- agent_state:/var/lib/heimdall
user: "1654:1654"
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:
heimdall:
condition: service_started
agent-state-init:
condition: service_completed_successfully
restart: unless-stopped
logging: *default-logging
# no networks: host networking
# 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
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:
name: heimdall-net
driver: bridge