From 43325ecf88334735bbdce57f718e8f55bab903c6 Mon Sep 17 00:00:00 2001 From: Mark Coleman Date: Thu, 4 Dec 2025 10:19:14 +0100 Subject: [PATCH 1/2] Add minimal instructions for NetBox Docker. --- README.md | 3 ++ docs/netbox-docker.md | 92 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 docs/netbox-docker.md diff --git a/README.md b/README.md index b6cd5d8..e7de3d0 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,9 @@ This [NetBox](http://netboxlabs.com/oss/netbox/) plugin introduces branching fun * NetBox v4.3 or later * PostgreSQL 12 or later +> [!TIP] +> To use NetBox Branching with NetBox Docker, click [here](./docs/netbox-docker.md) + ## Installation Brief installation instructions are provided below. For a complete installation guide, please refer to the included documentation. diff --git a/docs/netbox-docker.md b/docs/netbox-docker.md new file mode 100644 index 0000000..08062a4 --- /dev/null +++ b/docs/netbox-docker.md @@ -0,0 +1,92 @@ +# NetBox Branching with NetBox Docker + +NetBox Docker is _not_ officially supported by NetBox Labs. This page is intended as a _minimal_ guide to getting branching working on NetBox Docker. For additional configuration options, please consult the [NetBox Docker documentation.](https://github.com/netbox-community/netbox-docker) + +## Clone NetBox Docker and step into the repo + +``` +git clone --branch 3.4.1 https://github.com/netbox-community/netbox-docker.git +pushd netbox-docker +``` + +## Create a Dockerfile to install NetBox Branching + +``` +cat < Dockerfile-Plugins +FROM netboxcommunity/netbox:v4.4.6 +RUN uv pip install netboxlabs-netbox-branching==0.7.2 +EOF +``` + +## Create a docker-compose.override.yaml to include the custom image + +``` +cat < docker-compose.override.yml +services: + netbox: + image: netbox:v4.4.6-plugins + pull_policy: never + ports: + - "8000:8080" + build: + context: . + dockerfile: Dockerfile-Plugins + environment: + SKIP_SUPERUSER: "false" + SUPERUSER_EMAIL: "" + SUPERUSER_NAME: "admin" + SUPERUSER_PASSWORD: "admin" + healthcheck: + test: curl -f http://127.0.0.1:8080/login/ || exit 1 + start_period: 600s + timeout: 3s + interval: 15s + postgres: + ports: + - "5432:5432" + netbox-worker: + image: netbox:v4.4.6-plugins + pull_policy: never +EOF +``` + +## Create plugins.py to configure branching + +> [!TIP] +> Remember to insert your postgres password, the default for which can be found in `env/postgres.env` + +``` +cat < configuration/plugins.py +PLUGINS = ["netbox_branching"] # If you have multiple plugins, netbox-branching _must_ come last + +from netbox_branching.utilities import DynamicSchemaDict + +DATABASES = DynamicSchemaDict({ + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'netbox', # Database name + 'USER': 'netbox', # PostgreSQL username + 'PASSWORD': 'yourpassword', # PostgreSQL password + 'HOST': 'postgres', # Database server + 'PORT': '', # Database port (leave blank for default) + 'CONN_MAX_AGE': 300, # Max database connection age + } +}) + +DATABASE_ROUTERS = [ + 'netbox_branching.database.BranchAwareRouter', +] +EOF +``` + +## Build the NetBox image + +``` +docker compose build --no-cache +``` + +## Start NetBox Docker + +``` +docker compose up -d +``` \ No newline at end of file From edbf66fb6cbd7879beed5e456c8b495caba3bbdc Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 8 Dec 2025 10:51:54 -0500 Subject: [PATCH 2/2] Misc cleanup --- docs/netbox-docker.md | 43 +++++++++++++++++++++++-------------------- mkdocs.yml | 1 + 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/docs/netbox-docker.md b/docs/netbox-docker.md index 08062a4..8320c16 100644 --- a/docs/netbox-docker.md +++ b/docs/netbox-docker.md @@ -1,27 +1,30 @@ -# NetBox Branching with NetBox Docker +# Using Branching with NetBox Docker NetBox Docker is _not_ officially supported by NetBox Labs. This page is intended as a _minimal_ guide to getting branching working on NetBox Docker. For additional configuration options, please consult the [NetBox Docker documentation.](https://github.com/netbox-community/netbox-docker) -## Clone NetBox Docker and step into the repo +## Building a Docker Image with Branching + +### 1. Clone the `netbox-docker` repository ``` git clone --branch 3.4.1 https://github.com/netbox-community/netbox-docker.git pushd netbox-docker ``` -## Create a Dockerfile to install NetBox Branching +### 2. Create a Dockerfile -``` -cat < Dockerfile-Plugins +Create a Dockerfile in the root of the repository to include the `netbox-branching` plugin: + +```text title="Dockerfile-Plugins" FROM netboxcommunity/netbox:v4.4.6 RUN uv pip install netboxlabs-netbox-branching==0.7.2 -EOF ``` -## Create a docker-compose.override.yaml to include the custom image +### 3. Include the custom image -``` -cat < docker-compose.override.yml +Create a `docker-compose.override.yml` file to include the custom image: + +```yaml title="docker-compose.override.yml" services: netbox: image: netbox:v4.4.6-plugins @@ -47,17 +50,18 @@ services: netbox-worker: image: netbox:v4.4.6-plugins pull_policy: never -EOF ``` -## Create plugins.py to configure branching +### 4. Configure the plugin -> [!TIP] -> Remember to insert your postgres password, the default for which can be found in `env/postgres.env` +Create `plugins.py` to store the plugin's configuration. -``` -cat < configuration/plugins.py -PLUGINS = ["netbox_branching"] # If you have multiple plugins, netbox-branching _must_ come last +!!! tip + Remember to insert your postgres password, the default for which can be found in `env/postgres.env` + +```python title="configuration/plugins.py" +# If you have multiple plugins, netbox-branching _must_ come last +PLUGINS = ["netbox_branching"] from netbox_branching.utilities import DynamicSchemaDict @@ -76,17 +80,16 @@ DATABASES = DynamicSchemaDict({ DATABASE_ROUTERS = [ 'netbox_branching.database.BranchAwareRouter', ] -EOF ``` -## Build the NetBox image +### 5. Build the NetBox image ``` docker compose build --no-cache ``` -## Start NetBox Docker +### 6. Start NetBox Docker ``` docker compose up -d -``` \ No newline at end of file +``` diff --git a/mkdocs.yml b/mkdocs.yml index e013fd5..46ccd27 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -43,6 +43,7 @@ nav: - Syncing & Merging: 'using-branches/syncing-merging.md' - Reverting a Branch: 'using-branches/reverting-a-branch.md' - Best Practices: 'best-practices.md' + - NetBox Docker: 'netbox-docker.md' - REST API: 'rest-api.md' - Configuration: 'configuration.md' - Data Model: