version: '3.8'

services:
  netbox:
    image: netboxcommunity/netbox:v4.0
    depends_on:
      - postgres
      - redis
      - redis-cache
    ports:
      - "8000:8080"
    volumes:
      - netbox-media-files:/opt/netbox/netbox/media
      - netbox-reports-files:/opt/netbox/netbox/reports
      - netbox-scripts-files:/opt/netbox/netbox/scripts
    environment:
      - POSTGRES_DB=netbox
      - POSTGRES_USER=netbox
      - POSTGRES_PASSWORD=GeheimesNetboxPw123!
      - REDIS_PASSWORD=GeheimesRedisPw123!
      - SECRET_KEY=DasIstEinSehrLangerUndSichererNetboxGeheimSchluessel12345!
      - ALLOWED_HOSTS=*
      - DB_HOST=postgres
      - DB_PASSWORD=GeheimesNetboxPw123!
      - DB_USER=netbox
      - REDIS_HOST=redis
      - REDIS_CACHE_HOST=redis-cache
      - SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567
      - SUPERUSER_EMAIL=admin@example.com
      - SUPERUSER_NAME=admin
      - SUPERUSER_PASSWORD=adminpassword
      - MEDIA_ROOT=/opt/netbox/netbox/media  # Zwingt Netbox in den richtigen Ordner

  netbox-worker:
    image: netboxcommunity/netbox:v4.0
    depends_on:
      - netbox
    command:
      - /opt/netbox/venv/bin/python
      - /opt/netbox/netbox/manage.py
      - rqworker
    volumes:
      - netbox-media-files:/opt/netbox/netbox/media
      - netbox-reports-files:/opt/netbox/netbox/reports
      - netbox-scripts-files:/opt/netbox/netbox/scripts
    environment:
      - POSTGRES_DB=netbox
      - POSTGRES_USER=netbox
      - POSTGRES_PASSWORD=GeheimesNetboxPw123!
      - REDIS_PASSWORD=GeheimesRedisPw123!
      - SECRET_KEY=DasIstEinSehrLangerUndSichererNetboxGeheimSchluessel12345!
      - ALLOWED_HOSTS=*
      - DB_HOST=postgres
      - DB_PASSWORD=GeheimesNetboxPw123!
      - DB_USER=netbox
      - REDIS_HOST=redis
      - REDIS_CACHE_HOST=redis-cache
      - MEDIA_ROOT=/opt/netbox/netbox/media  # Zwingt auch den Worker in den richtigen Ordner

  postgres:
    image: postgres:15-alpine
    volumes:
      - netbox-postgres-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=netbox
      - POSTGRES_USER=netbox
      - POSTGRES_PASSWORD=GeheimesNetboxPw123!

  redis:
    image: redis:7-alpine
    command:
      - sh
      - -c
      - redis-server --appendonly yes --requirepass $$REDIS_PASSWORD
    volumes:
      - netbox-redis-data:/data
    environment:
      - REDIS_PASSWORD=GeheimesRedisPw123!

  redis-cache:
    image: redis:7-alpine
    command:
      - sh
      - -c
      - redis-server --requirepass $$REDIS_PASSWORD
    environment:
      - REDIS_PASSWORD=GeheimesRedisPw123!

volumes:
  netbox-postgres-data:
  netbox-redis-data:
  netbox-media-files:
  netbox-reports-files:
  netbox-scripts-files: