You've already forked ansible-netbox-inventory
compose stack modelled on the production netbox deployment (same pinned images, worker, healthchecks) minus traefik: the API is served straight on localhost and nothing survives an e2e-down.
106 lines
2.7 KiB
YAML
106 lines
2.7 KiB
YAML
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
# Copyright (C) 2026 Bryan Joshua Pedini
|
|
---
|
|
services:
|
|
netbox: &netbox
|
|
image: netboxcommunity/netbox:${NETBOX_VERSION}-${NETBOX_DOCKER_VERSION}
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
redis-cache:
|
|
condition: service_healthy
|
|
environment:
|
|
- API_TOKEN_PEPPER_1=${NETBOX_API_TOKEN_PEPPER_1}
|
|
- DB_HOST=postgres
|
|
- DB_NAME=${PSQL_NAME}
|
|
- DB_USER=${PSQL_USER}
|
|
- DB_PASSWORD=${PSQL_PASS}
|
|
- REDIS_HOST=redis
|
|
- REDIS_DATABASE=0
|
|
- REDIS_PASSWORD=${REDIS_PASS}
|
|
- REDIS_SSL=false
|
|
- REDIS_CACHE_HOST=redis-cache
|
|
- REDIS_CACHE_DATABASE=1
|
|
- REDIS_CACHE_PASSWORD=${REDIS_CACHE_PASS}
|
|
- REDIS_CACHE_SSL=false
|
|
- SECRET_KEY=${NETBOX_SECRET_KEY}
|
|
- SKIP_SUPERUSER=false
|
|
- SUPERUSER_NAME=${NETBOX_SUPERUSER_NAME}
|
|
- SUPERUSER_EMAIL=${NETBOX_SUPERUSER_EMAIL}
|
|
- SUPERUSER_PASSWORD=${NETBOX_SUPERUSER_PASS}
|
|
healthcheck:
|
|
test: curl -f http://localhost:8080/login/ || exit 1
|
|
# first boot runs every migration, give it plenty of headroom
|
|
start_period: 600s
|
|
timeout: 3s
|
|
interval: 15s
|
|
ports:
|
|
- "127.0.0.1:${NETBOX_HTTP_PORT}:8080"
|
|
networks:
|
|
- internal
|
|
|
|
netbox-worker:
|
|
<<: *netbox
|
|
command:
|
|
- /opt/netbox/venv/bin/python
|
|
- /opt/netbox/netbox/manage.py
|
|
- rqworker
|
|
depends_on:
|
|
netbox:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ps -aux | grep -v grep | grep -q rqworker || exit 1
|
|
start_period: 20s
|
|
timeout: 3s
|
|
interval: 15s
|
|
ports: []
|
|
|
|
postgres:
|
|
image: postgres:${PSQL_VERSION}
|
|
environment:
|
|
- POSTGRES_DB=${PSQL_NAME}
|
|
- POSTGRES_USER=${PSQL_USER}
|
|
- POSTGRES_PASSWORD=${PSQL_PASS}
|
|
healthcheck:
|
|
test: pg_isready -q -t 2 -d $$POSTGRES_DB -U $$POSTGRES_USER
|
|
start_period: 20s
|
|
timeout: 30s
|
|
interval: 10s
|
|
retries: 5
|
|
networks:
|
|
- internal
|
|
|
|
redis:
|
|
image: redis:${REDIS_VERSION}
|
|
command:
|
|
- sh
|
|
- -c
|
|
- redis-server --appendonly yes --requirepass $$REDIS_PASSWORD
|
|
environment:
|
|
- REDIS_PASSWORD=${REDIS_PASS}
|
|
healthcheck: &redis-healthcheck
|
|
test: '[ $$(redis-cli --pass "$${REDIS_PASSWORD}" ping) = ''PONG'' ]'
|
|
start_period: 5s
|
|
timeout: 3s
|
|
interval: 1s
|
|
retries: 5
|
|
networks:
|
|
- internal
|
|
|
|
redis-cache:
|
|
image: redis:${REDIS_VERSION}
|
|
command:
|
|
- sh
|
|
- -c
|
|
- redis-server --requirepass $$REDIS_PASSWORD
|
|
environment:
|
|
- REDIS_PASSWORD=${REDIS_CACHE_PASS}
|
|
healthcheck: *redis-healthcheck
|
|
networks:
|
|
- internal
|
|
|
|
networks:
|
|
internal:
|