# --------------------------------------------------------------- # IPAM — Docker Compose # --------------------------------------------------------------- # Deux profils : # - `sqlite` → ipam seul, base SQLite dans un volume # - `postgres` → ipam + postgres # # Usage : # docker compose -f docker/docker-compose.yml --profile sqlite up -d # docker compose -f docker/docker-compose.yml --profile postgres up -d # # Le mode `network_mode: host` est indispensable pour que la découverte # (ARP, mDNS, ping sweep, port scan) atteigne le LAN. Sans lui, le # container ne voit que le bridge Docker. # --------------------------------------------------------------- services: # ========================================================= # Service IPAM — variante SQLite (autonome, sans PostgreSQL) # ========================================================= ipam: build: context: .. dockerfile: docker/Dockerfile args: DATABASE_PROVIDER: sqlite image: ipam-homelab:sqlite container_name: ipam restart: unless-stopped network_mode: host environment: NODE_ENV: production PORT: 3000 HOSTNAME: 0.0.0.0 DATABASE_PROVIDER: sqlite DATABASE_URL: "file:/app/data/ipam.db" RUN_SEED: "${RUN_SEED:-false}" env_file: - ../.env volumes: - ipam-data:/app/data cap_add: - NET_RAW - NET_ADMIN healthcheck: test: ["CMD-SHELL", "wget -q --spider http://localhost:3000/ || exit 1"] interval: 30s timeout: 5s retries: 3 start_period: 30s profiles: ["sqlite"] # ========================================================= # Service IPAM — variante PostgreSQL # ========================================================= ipam-pg: build: context: .. dockerfile: docker/Dockerfile args: DATABASE_PROVIDER: postgresql image: ipam-homelab:postgres container_name: ipam restart: unless-stopped network_mode: host environment: NODE_ENV: production PORT: 3000 HOSTNAME: 0.0.0.0 DATABASE_PROVIDER: postgresql DATABASE_URL: "postgresql://ipam:${POSTGRES_PASSWORD:-ipam}@127.0.0.1:5432/ipam?schema=public" RUN_SEED: "${RUN_SEED:-false}" env_file: - ../.env cap_add: - NET_RAW - NET_ADMIN depends_on: postgres: condition: service_healthy healthcheck: test: ["CMD-SHELL", "wget -q --spider http://localhost:3000/ || exit 1"] interval: 30s timeout: 5s retries: 3 start_period: 30s profiles: ["postgres"] # ========================================================= # PostgreSQL (profil "postgres" uniquement) # ========================================================= postgres: image: postgres:16-alpine container_name: ipam-postgres restart: unless-stopped # network_mode host → expose le port 5432 directement sur l'hôte. network_mode: host environment: POSTGRES_USER: ipam POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-ipam}" POSTGRES_DB: ipam PGPORT: 5432 volumes: - ipam-postgres:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U ipam -d ipam"] interval: 5s timeout: 3s retries: 10 profiles: ["postgres"] volumes: ipam-data: driver: local ipam-postgres: driver: local