diff --git a/Dockerfile b/Dockerfile index 33bf28a..d4cf167 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,12 +35,12 @@ WORKDIR /opt/netbox RUN pip install -r requirements.txt COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py -COPY configuration/gunicorn_config.py /etc/netbox/ +COPY configuration/gunicorn_config.py /etc/netbox/config/ COPY docker/nginx.conf /etc/netbox-nginx/nginx.conf COPY docker/docker-entrypoint.sh docker-entrypoint.sh COPY startup_scripts/ /opt/netbox/startup_scripts/ COPY initializers/ /opt/netbox/initializers/ -COPY configuration/configuration.py /etc/netbox/configuration.py +COPY configuration/configuration.py /etc/netbox/config/configuration.py WORKDIR /opt/netbox/netbox @@ -48,7 +48,7 @@ ENTRYPOINT [ "/opt/netbox/docker-entrypoint.sh" ] VOLUME ["/etc/netbox-nginx/"] -CMD ["gunicorn", "-c /etc/netbox/gunicorn_config.py", "netbox.wsgi"] +CMD ["gunicorn", "-c /etc/netbox/config/gunicorn_config.py", "netbox.wsgi"] LABEL SRC_URL="$URL" diff --git a/Dockerfile.ldap b/Dockerfile.ldap index 5402eb7..86f402b 100644 --- a/Dockerfile.ldap +++ b/Dockerfile.ldap @@ -6,4 +6,4 @@ FROM $DOCKER_ORG/$DOCKER_REPO:$FROM_TAG RUN pip install django_auth_ldap COPY docker/ldap_config.docker.py /opt/netbox/netbox/netbox/ldap_config.py -COPY configuration/ldap_config.py /etc/netbox/ldap_config.py +COPY configuration/ldap_config.py /etc/netbox/config/ldap_config.py diff --git a/README.md b/README.md index ff57d66..1ee86ba 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ You should therefore adjust the configuration for production setups, at least th You may run this image in a cluster such as Docker Swarm, Kubernetes or OpenShift, but this is advanced level. -In this case, we encourage you to statically configure NetBox by starting from [NetBox's example config file][default-config], and mounting it into your container in the directory `/etc/netbox/` using the mechanism provided by your container platform (i.e. [Docker Swarm configs][swarm-config], [Kubernetes ConfigMap][k8s-config], [OpenShift ConfigMaps][openshift-config]). +In this case, we encourage you to statically configure NetBox by starting from [NetBox's example config file][default-config], and mounting it into your container in the directory `/etc/netbox/config/` using the mechanism provided by your container platform (i.e. [Docker Swarm configs][swarm-config], [Kubernetes ConfigMap][k8s-config], [OpenShift ConfigMaps][openshift-config]). But if you rather continue to configure your application through environment variables, you may continue to use [the built-in configuration file][docker-config]. We discourage storing secrets in environment variables, as environment variable are passed on to all sub-processes and may leak easily into other systems, e.g. error collecting tools that often collect all environment variables whenever an error occurs. diff --git a/configuration/configuration.py b/configuration/configuration.py index 62f3a66..7d704ae 100644 --- a/configuration/configuration.py +++ b/configuration/configuration.py @@ -141,7 +141,7 @@ PREFER_IPV4 = os.environ.get('PREFER_IPV4', 'False').lower() == 'true' # The file path where custom reports will be stored. A trailing slash is not needed. Note that the default value of # this setting is derived from the installed location. -REPORTS_ROOT = os.environ.get('REPORTS_ROOT', os.path.join(BASE_DIR, 'reports')) +REPORTS_ROOT = os.environ.get('REPORTS_ROOT', '/etc/netbox/reports') # Time zone (default: UTC) TIME_ZONE = os.environ.get('TIME_ZONE', 'UTC') diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 158defc..a2ad9b5 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -10,7 +10,7 @@ services: - postgres env_file: netbox.env volumes: - - ./configuration:/etc/netbox:ro + - ./configuration:/etc/netbox/config:ro command: - ./manage.py - test diff --git a/docker-compose.yml b/docker-compose.yml index 71735a8..40dc9bb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,11 +12,11 @@ services: volumes: - ./startup_scripts:/opt/netbox/startup_scripts:ro - ./initializers:/opt/netbox/initializers:ro - - ./configuration:/etc/netbox:ro + - ./configuration:/etc/netbox/config:ro - netbox-nginx-config:/etc/netbox-nginx/ - netbox-static-files:/opt/netbox/netbox/static - netbox-media-files:/opt/netbox/netbox/media - - netbox-report-files:/opt/netbox/netbox/reports + - netbox-report-files:/etc/netbox/reports:ro nginx: image: nginx:1.13-alpine command: nginx -g 'daemon off;' -c /etc/netbox-nginx/nginx.conf diff --git a/docker/configuration.docker.py b/docker/configuration.docker.py index fbca950..733887f 100644 --- a/docker/configuration.docker.py +++ b/docker/configuration.docker.py @@ -2,7 +2,7 @@ import importlib.util import sys try: - spec = importlib.util.spec_from_file_location('configuration', '/etc/netbox/configuration.py') + spec = importlib.util.spec_from_file_location('configuration', '/etc/netbox/config/configuration.py') module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) sys.modules['netbox.configuration'] = module diff --git a/docker/ldap_config.docker.py b/docker/ldap_config.docker.py index 50e999e..8d82173 100644 --- a/docker/ldap_config.docker.py +++ b/docker/ldap_config.docker.py @@ -2,7 +2,7 @@ import importlib.util import sys try: - spec = importlib.util.spec_from_file_location('ldap_config', '/etc/netbox/ldap_config.py') + spec = importlib.util.spec_from_file_location('ldap_config', '/etc/netbox/config/ldap_config.py') module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) sys.modules['netbox.ldap_config'] = module