From 2f32906f684d1fd606cf70f07a1789aa31c981f5 Mon Sep 17 00:00:00 2001 From: Arnaud Dartois Date: Sat, 18 Jul 2026 11:30:55 +0000 Subject: [PATCH] feat: add Docker Hub production docker-compose and docs --- docker/docker-compose.prod.yml | 121 +++++++++++++++++++++++++++++++++ readme.md | 54 +++++++++++++-- 2 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 docker/docker-compose.prod.yml diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml new file mode 100644 index 0000000..1b0093f --- /dev/null +++ b/docker/docker-compose.prod.yml @@ -0,0 +1,121 @@ +# ─── Heimdall — Production Docker Compose (Docker Hub) ────────── +# 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 +# +# Images are published by the CI pipeline on main branch pushes: +# eltruncho/heimdall-central:latest +# eltruncho/heimdall-agent:latest + +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:-heimdall} + 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 + + minio: + image: minio/minio:latest + command: server /data --console-address ":9001" + environment: + MINIO_ROOT_USER: ${MINIO_ROOT_USER:-heimdall} + MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-heimdall123} + ports: + - "${MINIO_API_PORT:-9000}:9000" + - "${MINIO_CONSOLE_PORT:-9001}:9001" + volumes: + - minio_data:/data + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 30s + restart: unless-stopped + logging: *default-logging + networks: + - heimdall-net + + heimdall-central: + image: eltruncho/heimdall-central:latest + environment: + DATABASE_URL: ${DATABASE_URL:-Host=postgresql;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall} + JWT__Key: ${JWT__Key} + JWT__Issuer: ${JWT__Issuer:-heimdall} + JWT__Audience: ${JWT__Audience:-heimdall-api} + ASPNETCORE_ENVIRONMENT: ${ASPNETCORE_ENVIRONMENT:-Production} + ASPNETCORE_URLS: http://+:8080 + Cors__AllowedOrigins: ${Cors__AllowedOrigins:-https://localhost:5001} + ports: + - "${CENTRAL_PORT:-5000}:8080" + depends_on: + postgresql: + condition: service_healthy + 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 + + heimdall-workers: + image: eltruncho/heimdall-central:latest + entrypoint: ["dotnet", "workers/Heimdall.Workers.dll"] + environment: + DATABASE_URL: ${DATABASE_URL:-Host=postgresql;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall} + ASPNETCORE_ENVIRONMENT: ${ASPNETCORE_ENVIRONMENT:-Production} + depends_on: + postgresql: + condition: service_healthy + restart: unless-stopped + logging: *default-logging + networks: + - heimdall-net + + heimdall-agent: + image: eltruncho/heimdall-agent:latest + environment: + HEIMDALL_CENTRAL_URL: ${HEIMDALL_CENTRAL_URL:-http://heimdall-central:8080} + HEIMDALL_SITE_TOKEN: ${HEIMDALL_SITE_TOKEN} + HEIMDALL_AGENT_NAME: ${HEIMDALL_AGENT_NAME:-agent-01} + depends_on: + - heimdall-central + restart: unless-stopped + logging: *default-logging + networks: + - heimdall-net + +volumes: + pgdata: + driver: local + minio_data: + driver: local + +networks: + heimdall-net: + driver: bridge diff --git a/readme.md b/readme.md index 4c3a716..928c1ac 100644 --- a/readme.md +++ b/readme.md @@ -27,7 +27,14 @@ Heimdall.Central (Api + Web + Workers) Heimdall.Agent ## Démarrage rapide -### 1. Docker (production) +### 1. Docker (production — Docker Hub) + +Les images pré-buildées sont disponibles sur [Docker Hub](https://hub.docker.com/repository/docker/eltruncho/heimdall) : + +| Image | Description | +|-------|-------------| +| `eltruncho/heimdall-central:latest` | API + Web UI + Workers | +| `eltruncho/heimdall-agent:latest` | Agent d'enregistrement | ```bash # Copier la configuration @@ -35,8 +42,8 @@ cp .env.example .env # Éditer les secrets (JWT__Key, mots de passe) nano .env -# Lancer -docker compose -f docker/docker-compose.yml up -d +# Lancer (pull images depuis Docker Hub) +docker compose -f docker/docker-compose.prod.yml up -d ``` Accès : @@ -45,7 +52,18 @@ Accès : - **Documentation API** : http://localhost:5000/scalar (dev) - **MinIO Console** : http://localhost:9001 -### 2. Développement +### 2. Build local (développement) + +```bash +cp .env.example .env +# Éditer les secrets +nano .env + +# Build & lancer depuis les sources +docker compose -f docker/docker-compose.yml up -d +``` + +### 3. Développement Prérequis : .NET 10 SDK, PostgreSQL 17 @@ -134,6 +152,34 @@ dotnet test ## Déploiement Docker +### Depuis Docker Hub (recommandé) + +```yaml +# docker-compose.prod.yml minimal +services: + postgresql: + image: postgres:17-alpine + environment: + POSTGRES_DB: heimdall + POSTGRES_USER: heimdall + POSTGRES_PASSWORD: + volumes: + - pgdata:/var/lib/postgresql/data + + heimdall-central: + image: eltruncho/heimdall-central:latest + environment: + DATABASE_URL: "Host=postgresql;Port=5432;Database=heimdall;Username=heimdall;Password=" + JWT__Key: "" + ports: + - "5000:8080" + depends_on: + postgresql: + condition: service_healthy +``` + +### Build local + ```yaml # docker-compose.yml minimal services: