version: "3.9"

services:
  postgres:
    image: postgres:16
    environment:
      POSTGRES_DB: netbox
      POSTGRES_USER: netbox
      POSTGRES_PASSWORD: SuperSicheresPasswort
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - netbox

  redis:
    image: redis:7-alpine
    command: redis-server --appendonly yes
    volumes:
      - redis_data:/data
    networks:
      - netbox

  netbox:
    image: netboxcommunity/netbox:latest
    depends_on:
      - postgres
      - redis
    environment:
      ALLOWED_HOSTS: "*"
      DB_NAME: netbox
      DB_USER: netbox
      DB_PASSWORD: SuperSicheresPasswort
      DB_HOST: postgres
      DB_PORT: 5432
      REDIS_HOST: redis
      REDIS_PORT: 6379
      REDIS_CACHE_HOST: redis
      REDIS_CACHE_PORT: 6379

      SECRET_KEY: "ERSETZE_DIESEN_STRING_MIT_EINEM_LANGEN_ZUFALLSWERT"

      SUPERUSER_NAME: admin
      SUPERUSER_EMAIL: admin@example.com
      SUPERUSER_PASSWORD: AdminPasswort123!

    volumes:
      - netbox_media:/opt/netbox/netbox/media
      - netbox_reports:/opt/netbox/netbox/reports
      - netbox_scripts:/opt/netbox/netbox/scripts

    ports:
      - "8000:8080"

    networks:
      - netbox

volumes:
  postgres_data:
  redis_data:
  netbox_media:
  netbox_reports:
  netbox_scripts:

networks:
  netbox:
    driver: overlay