Files
sven e7b53b6965 modified: .env
modified:   README.md
modified:   compose.yml
modified:   configuration.py
new file:   haproxy.cfg
new file:   init-patroni-users.sql
renamed:    entrypoint.sh -> netbox-entrypoint.sh
renamed:    Containerfile -> netbox.Containerfile
modified:   nginx.conf
new file:   patroni-entrypoint.sh
new file:   patroni.Containerfile
new file:   patroni.yml
2026-08-03 15:04:38 +02:00

196 lines
6.0 KiB
YAML

name: netbox
services:
# __ etcd (DCS for Patroni) __________________________________
etcd:
image: quay.io/coreos/etcd:${ETCD_VERSION}
restart: unless-stopped
network_mode: host
command: >
etcd
--data-dir /etcd-data
--listen-client-urls http://0.0.0.0:2379
--advertise-client-urls http://127.0.0.1:2379
--listen-peer-urls http://0.0.0.0:2380
--initial-advertise-peer-urls http://127.0.0.1:2380
--initial-cluster default=http://127.0.0.1:2380
--initial-cluster-token netbox-etcd
--initial-cluster-state new
volumes:
- etcd_data:/etcd-data
# __ Patroni node 1 (leader candidate, existing data) ________
patroni1:
image: git.luethi.co/sven/netbox-stack/patroni-postgres:${POSTGRES_VERSION}
build:
context: .
dockerfile: patroni.Containerfile
network: host
args:
POSTGRES_VERSION: ${POSTGRES_VERSION}
restart: unless-stopped
network_mode: host
depends_on:
- etcd
environment:
PATRONI_NAME: postgresql0
PATRONI_POSTGRESQL_LISTEN: 0.0.0.0:5432
PATRONI_POSTGRESQL_CONNECT_ADDRESS: localhost:5432
PATRONI_POSTGRESQL_DATA_DIR: /var/lib/postgresql/data
PATRONI_RESTAPI_LISTEN: 0.0.0.0:8008
PATRONI_RESTAPI_CONNECT_ADDRESS: localhost:8008
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "curl -sf http://localhost:8008/health || exit 1"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
# __ Patroni node 2 (replica) ________________________________
patroni2:
image: git.luethi.co/sven/netbox-stack/patroni-postgres:${POSTGRES_VERSION}
restart: unless-stopped
network_mode: host
depends_on:
patroni1:
condition: service_healthy
environment:
PATRONI_NAME: postgresql1
PATRONI_POSTGRESQL_LISTEN: 0.0.0.0:5433
PATRONI_POSTGRESQL_CONNECT_ADDRESS: localhost:5433
PATRONI_POSTGRESQL_DATA_DIR: /var/lib/postgresql/data
PATRONI_RESTAPI_LISTEN: 0.0.0.0:8009
PATRONI_RESTAPI_CONNECT_ADDRESS: localhost:8009
volumes:
- postgres_data2:/var/lib/postgresql/data
# __ Patroni node 3 (replica) ________________________________
patroni3:
image: git.luethi.co/sven/netbox-stack/patroni-postgres:${POSTGRES_VERSION}
restart: unless-stopped
network_mode: host
depends_on:
patroni1:
condition: service_healthy
environment:
PATRONI_NAME: postgresql2
PATRONI_POSTGRESQL_LISTEN: 0.0.0.0:5434
PATRONI_POSTGRESQL_CONNECT_ADDRESS: localhost:5434
PATRONI_POSTGRESQL_DATA_DIR: /var/lib/postgresql/data
PATRONI_RESTAPI_LISTEN: 0.0.0.0:8010
PATRONI_RESTAPI_CONNECT_ADDRESS: localhost:8010
volumes:
- postgres_data3:/var/lib/postgresql/data
# __ HAProxy (routes writes to leader) ________________________
haproxy:
image: git.luethi.co/sven/netbox-stack/haproxy:alpine
restart: unless-stopped
network_mode: host
depends_on:
- patroni1
volumes:
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
# __ Redis _____________________________________________________
redis:
image: git.luethi.co/sven/netbox-stack/redis:7-alpine
restart: unless-stopped
network_mode: host
command: redis-server --save 60 1
volumes:
- redis_data:/data:U
# __ NetBox web (Gunicorn) _____________________________________
netbox:
image: git.luethi.co/sven/netbox-stack/netbox:${NETBOX_VERSION}
build:
context: .
dockerfile: netbox.Containerfile
network: host
args:
NETBOX_VERSION: ${NETBOX_VERSION}
PYTHON_VERSION: ${PYTHON_VERSION}
HTTP_PROXY: ${HTTP_PROXY}
HTTPS_PROXY: ${HTTPS_PROXY}
NO_PROXY: ${NO_PROXY}
restart: unless-stopped
network_mode: host
depends_on:
- haproxy
- redis
volumes:
- ./configuration.py:/opt/netbox/netbox/netbox/configuration.py:ro
- netbox_custom_scripts:/opt/netbox/netbox/scripts:ro
- netbox_media:/opt/netbox/netbox/media:U
- netbox_static:/opt/netbox/netbox/static:U
environment:
GUNICORN_BIND: "localhost:8085"
GUNICORN_WORKERS: 4
GUNICORN_THREADS: 3
GUNICORN_TIMEOUT: 120
GUNICORN_MAX_REQUESTS: 5000
GUNICORN_MAX_REQUESTS_JITTER: 500
command: gunicorn
# __ NetBox RQ worker __________________________________________
netbox-worker:
image: git.luethi.co/sven/netbox-stack/netbox:${NETBOX_VERSION}
restart: unless-stopped
network_mode: host
depends_on:
- netbox
volumes:
- ./configuration.py:/opt/netbox/netbox/netbox/configuration.py:ro
- netbox_custom_scripts:/opt/netbox/netbox/scripts:ro
- netbox_media:/opt/netbox/netbox/media:U
- netbox_static:/opt/netbox/netbox/static:U
command: worker
# __ NetBox DNS transfer endpoint ______________________________
netbox-dns-transfer-endpoint:
image: git.luethi.co/sven/netbox-stack/netbox:${NETBOX_VERSION}
restart: unless-stopped
network_mode: host
depends_on:
- netbox
volumes:
- ./configuration.py:/opt/netbox/netbox/netbox/configuration.py:ro
command: dns-transfer-endpoint
# __ NGINX reverse proxy _______________________________________
nginx:
image: git.luethi.co/sven/netbox-stack/nginx:alpine
restart: unless-stopped
network_mode: host
depends_on:
- netbox
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- netbox_static:/static:ro
# __ BIND9 _____________________________________________________
bind9:
image: git.luethi.co/sven/netbox-stack/bind9:9.20
restart: unless-stopped
depends_on:
- netbox-dns-transfer-endpoint
network_mode: host
volumes:
- ./named.conf:/etc/bind/named.conf:ro
- ./rndc.key:/etc/bind/rndc.key:ro
volumes:
postgres_data:
postgres_data2:
postgres_data3:
etcd_data:
redis_data:
netbox_media:
netbox_static:
netbox_custom_scripts: