diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000000000000000000000000000000000000..832e21822113ff54dd9ecece4710271f1fc470b0 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,34 @@ +version: '3.4' +services: + netbox: + volumes: + - netbox-media-files:/opt/netbox/netbox/media:z,rw + - netbox-reports-files:/opt/netbox/netbox/reports:z,rw + - netbox-scripts-files:/opt/netbox/netbox/scripts:z,rw + # postgres + postgres: + volumes: + - netbox-postgres-data:/var/lib/postgresql/data + # redis + redis: + volumes: + - netbox-redis-data:/data + redis-cache: + volumes: + - netbox-redis-cache-data:/data + + +volumes: + netbox-media-files: + driver: local + netbox-postgres-data: + driver: local + netbox-redis-cache-data: + driver: local + netbox-redis-data: + driver: local + netbox-reports-files: + driver: local + netbox-scripts-files: + driver: local + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..a58825cce3cf576342a7ee642b98666397e5e108 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,85 @@ +version: '3.4' +services: + netbox: &netbox + image: code.europa.eu:4567/digit-c4/netbox-plugins:latest + depends_on: + - postgres + - redis + - redis-cache + ports: + - 8080:8080 + user: 'unit:root' + healthcheck: + start_period: 60s + timeout: 3s + interval: 15s + test: "curl -f http://localhost:8080/api/ || exit 1" + volumes: + - netbox-media-files:/opt/netbox/netbox/media:z,rw + - netbox-reports-files:/opt/netbox/netbox/reports:z,rw + - netbox-scripts-files:/opt/netbox/netbox/scripts:z,rw + netbox-worker: + <<: *netbox + depends_on: + netbox: + condition: service_healthy + command: + - /opt/netbox/venv/bin/python + - /opt/netbox/netbox/manage.py + - rqworker + healthcheck: + start_period: 20s + timeout: 3s + interval: 15s + test: "ps -aux | grep -v grep | grep -q rqworker || exit 1" + netbox-housekeeping: + <<: *netbox + depends_on: + netbox: + condition: service_healthy + command: + - /opt/netbox/housekeeping.sh + healthcheck: + start_period: 20s + timeout: 3s + interval: 15s + test: "ps -aux | grep -v grep | grep -q housekeeping || exit 1" + + # postgres + postgres: + image: docker.io/postgres:15-alpine + volumes: + - netbox-postgres-data:/var/lib/postgresql/data + + # redis + redis: + image: docker.io/redis:7-alpine + command: + - sh + - -c # this is to evaluate the $REDIS_PASSWORD from the env + - redis-server --appendonly yes --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose + volumes: + - netbox-redis-data:/data + redis-cache: + image: docker.io/redis:7-alpine + command: + - sh + - -c # this is to evaluate the $REDIS_PASSWORD from the env + - redis-server --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose + volumes: + - netbox-redis-cache-data:/data + +volumes: + netbox-media-files: + driver: local + netbox-postgres-data: + driver: local + netbox-redis-cache-data: + driver: local + netbox-redis-data: + driver: local + netbox-reports-files: + driver: local + netbox-scripts-files: + driver: local + diff --git a/tests/docker-compose.test.yml b/tests/docker-compose.test.yml new file mode 100644 index 0000000000000000000000000000000000000000..fa65ff8cd58a964d182d6cf4b589815f854bc1ff --- /dev/null +++ b/tests/docker-compose.test.yml @@ -0,0 +1,10 @@ +version: '3.4' +services: + netbox: + env_file: env/netbox.env + postgres: + env_file: env/postgres.env + redis: + env_file: env/redis.env + redis-cache: + env_file: env/redis-cache.env diff --git a/tests/env/netbox.env b/tests/env/netbox.env new file mode 100644 index 0000000000000000000000000000000000000000..9e490d01989d61487747ab229c16101e5325b475 --- /dev/null +++ b/tests/env/netbox.env @@ -0,0 +1,34 @@ +CORS_ORIGIN_ALLOW_ALL=True +DB_HOST=postgres +DB_NAME=netbox +DB_PASSWORD=J5brHrAXFLQSif0K +DB_USER=netbox +EMAIL_FROM=netbox@bar.com +EMAIL_PASSWORD= +EMAIL_PORT=25 +EMAIL_SERVER=localhost +EMAIL_SSL_CERTFILE= +EMAIL_SSL_KEYFILE= +EMAIL_TIMEOUT=5 +EMAIL_USERNAME=netbox +# EMAIL_USE_SSL and EMAIL_USE_TLS are mutually exclusive, i.e. they can't both be `true`! +EMAIL_USE_SSL=false +EMAIL_USE_TLS=false +GRAPHQL_ENABLED=true +HOUSEKEEPING_INTERVAL=86400 +MEDIA_ROOT=/opt/netbox/netbox/media +METRICS_ENABLED=false +REDIS_CACHE_DATABASE=1 +REDIS_CACHE_HOST=redis-cache +REDIS_CACHE_INSECURE_SKIP_TLS_VERIFY=false +REDIS_CACHE_PASSWORD=t4Ph722qJ5QHeQ1qfu36 +REDIS_CACHE_SSL=false +REDIS_DATABASE=0 +REDIS_HOST=redis +REDIS_INSECURE_SKIP_TLS_VERIFY=false +REDIS_PASSWORD=H733Kdjndks81 +REDIS_SSL=false +RELEASE_CHECK_URL=https://api.github.com/repos/netbox-community/netbox/releases +SECRET_KEY=r(m)9nLGnz$(_q3N4z1k(EFsMCjjjzx08x9VhNVcfd%6RF#r!6DE@+V5Zk2X +SKIP_SUPERUSER=true +WEBHOOKS_ENABLED=true diff --git a/tests/env/postgres.env b/tests/env/postgres.env new file mode 100644 index 0000000000000000000000000000000000000000..bb7b53c65e01116028fea4898931bbf9bbbeb92e --- /dev/null +++ b/tests/env/postgres.env @@ -0,0 +1,3 @@ +POSTGRES_DB=netbox +POSTGRES_PASSWORD=J5brHrAXFLQSif0K +POSTGRES_USER=netbox diff --git a/tests/env/redis-cache.env b/tests/env/redis-cache.env new file mode 100644 index 0000000000000000000000000000000000000000..6285c33a2d8d5ed34340d0477d467d5206031590 --- /dev/null +++ b/tests/env/redis-cache.env @@ -0,0 +1 @@ +REDIS_PASSWORD=t4Ph722qJ5QHeQ1qfu36 diff --git a/tests/env/redis.env b/tests/env/redis.env new file mode 100644 index 0000000000000000000000000000000000000000..44a19871f3415dc06fd61ab57e7de9494d75c2b6 --- /dev/null +++ b/tests/env/redis.env @@ -0,0 +1 @@ +REDIS_PASSWORD=H733Kdjndks81