-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Build
THIS TEXT IS CURRENTLY A DRAFT and applies to the MR #159
This document describes two different intentions:
- Enhance the image: Adjust the existing Docker image to your organization's needs. This can reduce the number of environment variables you'd have to configure or you can ship a default configuration by embedding your initializer yaml files.
-
Build the image from scratch: This is mostly useful to you when you work on
netbox-dockeritself.
The purpose of enhancing the image is usually to embed additional scripts or change the default configuration file.
This usually works by using the netboxcommunity/netbox image as base image:
FROM netboxcommunity/netbox:v2.6.6
COPY my_configuration.py /etc/netbox/config/configuration.py
COPY my_startup_scripts/ /opt/netbox/startup_scripts/
COPY my_initializers/ /opt/netbox/initializers/
COPY my_reports/ /etc/netbox/reports/
COPY my_scripts/ /etc/netbox/scriptsYou don't have to add all the files. But usually you'd use a selection of them.
The netbox-docker image is very advanced and has a rather complex build system.
That's why all of the complexity was captured in a few files:
-
build.sh: This script is called by all the others. Run./build.sh --helpto see all the options. -
build-all.sh: This script builds all versions of the Netbox Docker Image, i.e. releases (e.g.v2.6.6), pre-releases (e.g.v2.6-beta1),latestandsnapshot. -
build-branches.sh: Builds themasterGit branch aslatest, thedevelopGit branch assnapshotand thedevelop-*branch asdevelop-*. -
build-latest.sh: Queries Github to get the most recent tag. When launched withPRERELEASE=trueit will build a pre-release tag (usually beta releases) if the version of the pre-release is newer than the newest release tag. This produces a version likev2.6.6and also tagsv2.6.
You can still build the image manually using docker build.
If you want to do that, you must pass at least one build argument to Docker:
The NETBOX_PATH.
This build argument must be a path to a folder that contains all the Netbox files.
So, full instructions would look like this:
git clone https://github.com/netbox-community/netbox-docker.git
cd netbox-docker
git clone https://github.com/netbox-community/netbox.git netbox
docker build --build-args "NETBOX_PATH=netbox" --target main .The Docker file knows multiple build targets:
-
builder: It's goal is to compile all the Python dependencies. Thereby the other targets can be kept slimmer because they don't need to have all the build dependencies installed. It's also good for caching. -
main: Extendsbuilderand adds all the Netbox code and all the configuration files. -
ldap: Extendsmainand adds ldap-related dependencies and configuration files.
There are automatic builds configured on Docker Hub, which are trigger once a day and on every commit to the master branch of netbox-docker.
This automatic build relies on the same /build*.sh files as described above.
The default commands of Docker Hub are overwritten using the files in /hooks/*.
To learn more about the automatic builds read the DOCKER_HUB.md file.