# NetBox - DCIM/IPAM
# Port: 8443 -> 8080
# URL: https://nb.vish.gg
# Network documentation, device inventory, and IP address management

services:
  netbox:
    image: linuxserver/netbox:latest
    container_name: netbox
    depends_on:
      netbox-db:
        condition: service_healthy
      netbox-redis:
        condition: service_healthy
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Los_Angeles
      - SUPERUSER_EMAIL=${SUPERUSER_EMAIL}
      - SUPERUSER_PASSWORD="REDACTED_PASSWORD"
      - ALLOWED_HOST=*
      - DB_HOST=netbox-db
      - DB_PORT=5432
      - DB_NAME=netbox
      - DB_USER=netbox
      - DB_PASSWORD="REDACTED_PASSWORD"
      - REDIS_HOST=netbox-redis
      - REDIS_PORT=6379
      - REDIS_PASSWORD="REDACTED_PASSWORD"
      - REDIS_DB_TASK=0
      - REDIS_DB_CACHE=1
    volumes:
      - /home/homelab/docker/netbox/config:/config
    ports:
      - "8443:8000"
    restart: unless-stopped

  netbox-db:
    image: postgres:16-alpine
    container_name: netbox-db
    healthcheck:
      test: ["CMD", "pg_isready", "-q", "-d", "netbox", "-U", "netbox"]
      interval: 10s
      timeout: 5s
      retries: 10
    volumes:
      - /home/homelab/docker/netbox/db:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: netbox
      POSTGRES_USER: netbox
      POSTGRES_PASSWORD: "REDACTED_PASSWORD"
    restart: unless-stopped

  netbox-redis:
    image: redis:7-alpine
    container_name: netbox-redis
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping || exit 1"]
      interval: 10s
      timeout: 5s
      retries: 5
    command: redis-server --appendonly yes --requirepass REDACTED_PASSWORD
    volumes:
      - /home/homelab/docker/netbox/redis:/data
    restart: unless-stopped
