-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Build
Christian Mäder edited this page Jun 2, 2020
·
15 revisions
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 Docker image has a rather complex build system.
That's why all of the complexity is captured in a few build scripts:
-
build.sh: This is the main build script. It is called by all the other scripts. Run./build.sh --helpto see all the options. -
build-next.sh: Builds themasterGit branch aslatest, thedevelopGit branch assnapshotand thedevelop-*branches 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.
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 based on Github Actions, which are trigger once a day and on every commit to the master branch of netbox-docker.
The automatic build relies on the same /build*.sh files as described above.