138 lines
3.9 KiB
YAML
138 lines
3.9 KiB
YAML
services:
|
|
netbox:
|
|
image: docker.io/netboxcommunity/netbox:v4.7-5.1.1
|
|
container_name: netbox
|
|
restart: unless-stopped
|
|
user: "netbox:root"
|
|
ports:
|
|
- "127.0.0.1:8000:8080"
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
GRANIAN_WORKERS: "2"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
redis-cache:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./configuration:/etc/netbox/config:z,ro
|
|
- netbox-media-files:/opt/netbox/netbox/media
|
|
- netbox-reports-files:/opt/netbox/netbox/reports
|
|
- netbox-scripts-files:/opt/netbox/netbox/scripts
|
|
networks:
|
|
- default
|
|
- proxy
|
|
labels:
|
|
- "traefik.enable=true"
|
|
- "traefik.http.services.netbox.loadbalancer.server.port=8080"
|
|
|
|
# Prod Router
|
|
- "traefik.http.routers.netbox.rule=Host(`netbox.forust.xyz`)"
|
|
- "traefik.http.routers.netbox.entrypoints=websecure"
|
|
- "traefik.http.routers.netbox.middlewares=security-headers@file"
|
|
- "traefik.http.routers.netbox.tls.certresolver=letsencrypt"
|
|
# Local Router
|
|
- "traefik.http.routers.netbox-local.rule=Host(`netbox.workstation.internal`)"
|
|
- "traefik.http.routers.netbox-local.entrypoints=websecure"
|
|
- "traefik.http.routers.netbox-local.tls=true"
|
|
healthcheck:
|
|
test: ["CMD", "/opt/netbox/health.sh"]
|
|
start_period: 600s
|
|
timeout: 5s
|
|
interval: 15s
|
|
retries: 10
|
|
|
|
netbox-worker:
|
|
image: docker.io/netboxcommunity/netbox:v4.7-5.1.1
|
|
container_name: netbox-worker
|
|
restart: unless-stopped
|
|
user: "netbox:root"
|
|
command:
|
|
- /opt/netbox/venv/bin/python
|
|
- /opt/netbox/netbox/manage.py
|
|
- rqworker
|
|
env_file:
|
|
- .env
|
|
depends_on:
|
|
netbox:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./configuration:/etc/netbox/config:z,ro
|
|
- netbox-media-files:/opt/netbox/netbox/media
|
|
- netbox-reports-files:/opt/netbox/netbox/reports
|
|
- netbox-scripts-files:/opt/netbox/netbox/scripts
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "ps -ef | grep -q '[r]qworker'"]
|
|
start_period: 30s
|
|
timeout: 5s
|
|
interval: 15s
|
|
retries: 10
|
|
|
|
postgres:
|
|
image: docker.io/postgres:18.6-alpine
|
|
container_name: netbox-postgres
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_DB: "${POSTGRES_DB:?POSTGRES_DB must be set}"
|
|
POSTGRES_USER: "${POSTGRES_USER:?POSTGRES_USER must be set}"
|
|
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set}"
|
|
volumes:
|
|
- netbox-postgres:/var/lib/postgresql
|
|
healthcheck:
|
|
test: ["CMD-SHELL", 'pg_isready -q -t 2 -d "$${POSTGRES_DB}" -U "$${POSTGRES_USER}"']
|
|
start_period: 20s
|
|
timeout: 5s
|
|
interval: 10s
|
|
retries: 10
|
|
|
|
redis:
|
|
image: docker.io/valkey/valkey:9.1.2-alpine
|
|
container_name: netbox-redis
|
|
restart: unless-stopped
|
|
command:
|
|
- sh
|
|
- -c
|
|
- valkey-server --appendonly yes --requirepass "$$REDIS_PASSWORD"
|
|
environment:
|
|
REDIS_PASSWORD: "${REDIS_PASSWORD:?REDIS_PASSWORD must be set}"
|
|
volumes:
|
|
- netbox-redis-data:/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", 'valkey-cli --pass "$${REDIS_PASSWORD}" ping | grep -q PONG']
|
|
start_period: 5s
|
|
timeout: 5s
|
|
interval: 5s
|
|
retries: 10
|
|
|
|
redis-cache:
|
|
image: docker.io/valkey/valkey:9.1.2-alpine
|
|
container_name: netbox-redis-cache
|
|
restart: unless-stopped
|
|
command:
|
|
- sh
|
|
- -c
|
|
- valkey-server --requirepass "$$REDIS_CACHE_PASSWORD"
|
|
environment:
|
|
REDIS_CACHE_PASSWORD: "${REDIS_CACHE_PASSWORD:?REDIS_CACHE_PASSWORD must be set}"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", 'valkey-cli --pass "$${REDIS_CACHE_PASSWORD}" ping | grep -q PONG']
|
|
start_period: 5s
|
|
timeout: 5s
|
|
interval: 5s
|
|
retries: 10
|
|
|
|
volumes:
|
|
netbox-media-files:
|
|
netbox-reports-files:
|
|
netbox-scripts-files:
|
|
netbox-postgres:
|
|
netbox-redis-data:
|
|
|
|
networks:
|
|
default:
|
|
proxy:
|
|
external: true
|