From 236cf1ba5fd4aab2584b389998c68a24abf92dbb Mon Sep 17 00:00:00 2001 From: Vincent Simonin Date: Fri, 22 May 2026 17:45:25 +0200 Subject: [PATCH 1/2] :sparkles: Add BASE_PATH functionnality --- Dockerfile | 6 ++++-- configuration/base_path.py | 3 +++ entrypoint.sh => docker/entrypoint.sh | 0 docker/launch-netbox.sh | 29 +++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 configuration/base_path.py rename entrypoint.sh => docker/entrypoint.sh (100%) create mode 100755 docker/launch-netbox.sh diff --git a/Dockerfile b/Dockerfile index 8e9ba9b..4f3b5a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,10 +6,12 @@ COPY plugin_requirements.txt /opt/netbox/ RUN /usr/local/bin/uv pip install -r /opt/netbox/plugin_requirements.txt COPY configuration/plugins.py /etc/netbox/config/plugins.py +COPY configuration/base_path.py /etc/netbox/config/base_path.py COPY configuration/supervisord.conf /etc/supervisor/conf.d/supervisord.conf -COPY entrypoint.sh /opt/netbox/entrypoint.sh +COPY docker/entrypoint.sh /opt/netbox/entrypoint.sh +COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh -LABEL internal_version="4.6.1.0" +LABEL internal_version="4.6.1.1" LABEL prometheus_scrape="true" LABEL prometheus_address="netbox:8080" diff --git a/configuration/base_path.py b/configuration/base_path.py new file mode 100644 index 0000000..b8d456c --- /dev/null +++ b/configuration/base_path.py @@ -0,0 +1,3 @@ +from os import environ + +BASE_PATH = environ.get("BASE_PATH", "") diff --git a/entrypoint.sh b/docker/entrypoint.sh similarity index 100% rename from entrypoint.sh rename to docker/entrypoint.sh diff --git a/docker/launch-netbox.sh b/docker/launch-netbox.sh new file mode 100755 index 0000000..0844457 --- /dev/null +++ b/docker/launch-netbox.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +if [ -n "$BASE_PATH" ]; then + STATIC_PATH="/${BASE_PATH}static" +else + STATIC_PATH="/static" +fi + +echo $STATIC_PATH + +exec granian \ + --host "::" \ + --port "8080" \ + --interface "wsgi" \ + --no-ws \ + --workers "${GRANIAN_WORKERS:-4}" \ + --respawn-failed-workers \ + --backpressure "${GRANIAN_BACKPRESSURE:-${GRANIAN_WORKERS:-4}}" \ + --loop "uvloop" \ + --log \ + --log-level "info" \ + --access-log \ + --working-dir "/opt/netbox/netbox/" \ + --static-path-route "${STATIC_PATH}" \ + --static-path-mount "/opt/netbox/netbox/static/" \ + --static-path-dir-to-file index.html \ + --pid-file "/tmp/granian.pid" \ + "${GRANIAN_EXTRA_ARGS[@]}" \ + "netbox.granian:application" From 6d94064dd291058cd246c52b7df036c0704a39c7 Mon Sep 17 00:00:00 2001 From: Vincent Simonin Date: Fri, 22 May 2026 17:57:23 +0200 Subject: [PATCH 2/2] Update README file --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 087927d..1265284 100644 --- a/README.md +++ b/README.md @@ -22,5 +22,7 @@ On your favorite terminal (that we know the best terminal is env TAG=latest IMAGE=saashup/netbox-docker docker compose up -d ``` +Unlike [the official Netbox Docker distribution](https://github.com/netbox-community/netbox-docker), we have acivated the [BASE_PATH](https://netboxlabs.com/docs/netbox/configuration/system/#base_path) environment variable. + # Hosting Check https://saashup.com for more information.