version: '3.8'

services:
  netbox:
    image: netboxcommunity/netbox:v4.0-2.8.2
    depends_on:
      - postgres
      - redis
      - redis-cache
    env_file:
      - ./netbox.env
    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

  netbox-worker:
    image: netboxcommunity/netbox:v4.0-2.8.2
    depends_on:
      - netbox
    env_file:
      - ./netbox.env
    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

  postgres:
    image: postgres:15-alpine
    env_file:
      - ./netbox.env
    volumes:
      - netbox-postgres-data:/var/lib/postgresql/data

  redis:
    image: redis:7-alpine
    command:
      - sh
      - -c
      - redis-server --appendonly yes --requirepass $$REDIS_PASSWORD
    env_file:
      - ./netbox.env
    volumes:
      - netbox-redis-data:/data

  redis-cache:
    image: redis:7-alpine
    command:
      - sh
      - -c
      - redis-server --requirepass $$REDIS_PASSWORD
    env_file:
      - ./netbox.env

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