# NetBox - DCIM/IPAM
# Port: 8000
# Network documentation and IPAM

version: "3.9"
services:
  netbox-redis:
    image: redis
    container_name: NETBOX-REDIS
    hostname: netbox-redis
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping || exit 1"]
    command:
      - sh
      - -c
      - redis-server --appendonly yes --requirepass REDACTED_PASSWORD
    user: 1026:100
    volumes:
      - /volume1/docker/netbox/redis:/data
    environment:
      - REDIS_PASSWORD="REDACTED_PASSWORD"  # pragma: allowlist secret
    restart: unless-stopped

  netbox-db:
    image: postgres
    container_name: NETBOX-POSTGRES-DB
    hostname: netbox-db
    healthcheck:
      test: ["CMD", "pg_isready", "-q", "-d", "netbox", "-U", "netbox-user"]
      timeout: 45s
      interval: 10s
      retries: 10
    user: 1026:100
    volumes:
      - /volume1/docker/netbox/db:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: netbox
      POSTGRES_USER: netbox-user
      POSTGRES_PASSWORD: "REDACTED_PASSWORD"  # pragma: allowlist secret
    restart: unless-stopped

  netbox:
    image: linuxserver/netbox:latest
    container_name: NETBOX
    hostname: netbox
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://10.0.0.100:9458/ || exit 1
    environment:
      - PUID=1026
      - PGID=100
      - TZ=America/Los_Angeles
      - SUPERUSER_EMAIL=your-email@example.com
      - SUPERUSER_PASSWORD="REDACTED_PASSWORD"  # pragma: allowlist secret
      - ALLOWED_HOST=10.0.0.100
      - DB_HOST=netbox-db
      - DB_PORT=5432
      - DB_NAME=netbox
      - DB_USER=netbox-user
      - DB_PASSWORD="REDACTED_PASSWORD"  # pragma: allowlist secret
      - REDIS_HOST=netbox-redis
      - REDIS_PORT=6379
      - REDIS_PASSWORD="REDACTED_PASSWORD"  # pragma: allowlist secret
      - REDIS_DB_TASK=0
      - REDIS_DB_CACHE=1
    volumes:
      - /volume1/docker/netbox/config:/config
    ports:
      - 10.0.0.100:9458:8000
    restart: unless-stopped
    depends_on:
      netbox-redis:
        condition: service_healthy
      netbox-db:
        condition: service_healthy
