Refactor docker-compose.yml for shared volumes and networks

Updated Docker Compose configuration to use shared volumes and defined networks.
This commit is contained in:
drice000 2026-01-01 16:34:05 -05:00 committed by GitHub
parent 7d6f00662c
commit 929203f3c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,3 +1,5 @@
version: "3.8"
services: services:
netbox: &netbox netbox: &netbox
image: docker.io/netboxcommunity/netbox:${VERSION-v4.4-3.4.1} image: docker.io/netboxcommunity/netbox:${VERSION-v4.4-3.4.1}
@ -12,11 +14,16 @@ services:
start_period: 90s start_period: 90s
timeout: 3s timeout: 3s
interval: 15s interval: 15s
networks:
qnet-static-bond0-ae19be:
ipv4_address: 192.168.10.150
NetBoxNet: {}
volumes: volumes:
- ./configuration:/etc/netbox/config:z,ro - /share/Container/netbox/configuration:/etc/netbox/config:ro
- netbox-media-files:/opt/netbox/netbox/media:rw - /share/Container/netbox/media:/opt/netbox/netbox/media:rw
- netbox-reports-files:/opt/netbox/netbox/reports:rw - /share/Container/netbox/reports:/opt/netbox/netbox/reports:rw
- netbox-scripts-files:/opt/netbox/netbox/scripts:rw - /share/Container/netbox/scripts:/opt/netbox/netbox/scripts:rw
netbox-worker: netbox-worker:
<<: *netbox <<: *netbox
depends_on: depends_on:
@ -26,62 +33,68 @@ services:
- /opt/netbox/venv/bin/python - /opt/netbox/venv/bin/python
- /opt/netbox/netbox/manage.py - /opt/netbox/netbox/manage.py
- rqworker - rqworker
networks:
NetBoxNet: {}
healthcheck: healthcheck:
test: ps -aux | grep -v grep | grep -q rqworker || exit 1 test: ps -aux | grep -v grep | grep -q rqworker || exit 1
start_period: 20s start_period: 20s
timeout: 3s timeout: 3s
interval: 15s interval: 15s
# postgres
postgres: postgres:
image: docker.io/postgres:17-alpine image: docker.io/postgres:17-alpine
env_file: env/postgres.env
networks:
NetBoxNet:
ipv4_address: 172.31.30.10
healthcheck: healthcheck:
test: pg_isready -q -t 2 -d $$POSTGRES_DB -U $$POSTGRES_USER test: pg_isready -q -t 2 -d $$POSTGRES_DB -U $$POSTGRES_USER
start_period: 20s start_period: 20s
timeout: 30s timeout: 30s
interval: 10s interval: 10s
retries: 5 retries: 5
env_file: env/postgres.env
volumes: volumes:
- netbox-postgres-data:/var/lib/postgresql/data - /share/Container/netbox/postgres:/var/lib/postgresql/data
# redis
redis: redis:
image: docker.io/valkey/valkey:8.1-alpine image: docker.io/valkey/valkey:8.1-alpine
env_file: env/redis.env
command: command:
- sh - sh
- -c # this is to evaluate the $REDIS_PASSWORD from the env - -c
- valkey-server --appendonly yes --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose - valkey-server --appendonly yes --requirepass $$REDIS_PASSWORD
networks:
NetBoxNet:
ipv4_address: 172.31.30.11
healthcheck: &redis-healthcheck healthcheck: &redis-healthcheck
test: '[ $$(valkey-cli --pass "$${REDIS_PASSWORD}" ping) = ''PONG'' ]' test: '[ $$(valkey-cli --pass "$${REDIS_PASSWORD}" ping) = ''PONG'' ]'
start_period: 5s start_period: 5s
timeout: 3s timeout: 3s
interval: 1s interval: 1s
retries: 5 retries: 5
env_file: env/redis.env
volumes: volumes:
- netbox-redis-data:/data - /share/Container/netbox/redis:/data
redis-cache: redis-cache:
image: docker.io/valkey/valkey:8.1-alpine image: docker.io/valkey/valkey:8.1-alpine
env_file: env/redis-cache.env
command: command:
- sh - sh
- -c # this is to evaluate the $REDIS_PASSWORD from the env - -c
- valkey-server --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose - valkey-server --requirepass $$REDIS_PASSWORD
networks:
NetBoxNet:
ipv4_address: 172.31.30.12
healthcheck: *redis-healthcheck healthcheck: *redis-healthcheck
env_file: env/redis-cache.env
volumes: volumes:
- netbox-redis-cache-data:/data - /share/Container/netbox/redis-cache:/data
volumes: networks:
netbox-media-files: qnet-static-bond0-ae19be:
driver: local external: true
netbox-postgres-data:
driver: local NetBoxNet:
netbox-redis-cache-data: driver: bridge
driver: local ipam:
netbox-redis-data: config:
driver: local - subnet: 172.31.30.0/24
netbox-reports-files:
driver: local
netbox-scripts-files:
driver: local