Merge pull request #116 from cimnine/docker-hub_build_system
Build system for hub.docker.com
This commit is contained in:
commit
1e002846ef
66
DOCKER_HUB.md
Normal file
66
DOCKER_HUB.md
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
# cloud.docker.com Configuration
|
||||||
|
|
||||||
|
The automatic build is configured in cloud.docker.com.
|
||||||
|
|
||||||
|
The following build configuration is expected:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Source Repository: github.com/netbox-community/netbox-docker
|
||||||
|
Build Location: Build on Docker Hub's infrastructure
|
||||||
|
Autotest: Internal and External Pull Requests
|
||||||
|
Repository Links: Enable for Base Image
|
||||||
|
Build Rules:
|
||||||
|
- Source Type: Branch
|
||||||
|
Source: master
|
||||||
|
Docker Tag: branches-main
|
||||||
|
Dockerfile location: Dockerfile
|
||||||
|
- Source Type: Branch
|
||||||
|
Source: master
|
||||||
|
Docker Tag: branches-ldap
|
||||||
|
Dockerfile location: Dockerfile.ldap
|
||||||
|
- Source Type: Branch
|
||||||
|
Source: master
|
||||||
|
Docker Tag: prerelease-main
|
||||||
|
Dockerfile location: Dockerfile
|
||||||
|
- Source Type: Branch
|
||||||
|
Source: master
|
||||||
|
Docker Tag: prerelease-ldap
|
||||||
|
Dockerfile location: Dockerfile.ldap
|
||||||
|
- Source Type: Branch
|
||||||
|
Source: master
|
||||||
|
Docker Tag: release-main
|
||||||
|
Dockerfile location: Dockerfile
|
||||||
|
- Source Type: Branch
|
||||||
|
Source: master
|
||||||
|
Docker Tag: release-ldap
|
||||||
|
Dockerfile location: Dockerfile.ldap
|
||||||
|
Build Environment Variables:
|
||||||
|
# Create an app on Github and use it's OATH credentials here
|
||||||
|
- Key: GITHUB_OAUTH_CLIENT_ID
|
||||||
|
Value: <secret>
|
||||||
|
- Key: GITHUB_OAUTH_CLIENT_SECRET
|
||||||
|
Value: <secret>
|
||||||
|
Build Triggers:
|
||||||
|
- Name: Cron Trigger
|
||||||
|
# Use this trigger in combination with e.g. https://cron-job.org in order to regularly schedule builds
|
||||||
|
```
|
||||||
|
|
||||||
|
## Background Knowledge
|
||||||
|
|
||||||
|
The build system of cloud.docker.com is not made for this kind of project.
|
||||||
|
But we found a way to make it work, and this is how:
|
||||||
|
|
||||||
|
1. The docker hub build system [allows to overwrite the scripts that get executed
|
||||||
|
for `build`, `test` and `push`](overwrite). See `hooks/*`.
|
||||||
|
2. Shared functionality of the scripts `build`, `test` and `push` is extracted to `hooks/common`.
|
||||||
|
3. The `build` script runs `run_build()` from `hooks/common`.
|
||||||
|
This triggers either `build-branches.sh`, `build-latest.sh` or directly `build.sh`.
|
||||||
|
4. The `test` script just invokes `docker-compose` commands.
|
||||||
|
5. The `push` script runs `run_build()` from `hooks/common` with a `--push-only` flag.
|
||||||
|
This causes the `build.sh` script to not re-build the Docker image, but just the just built image.
|
||||||
|
|
||||||
|
The _Docker Tag_ configuration setting is misused to select the type (_release_, _prerelease_, _branches_) of the build as well as the variant (_main_, _ldap_).
|
||||||
|
|
||||||
|
The _Dockerfile location_ configuration setting is completely ignored by the build scripts.
|
||||||
|
|
||||||
|
[overwrite]: https://docs.docker.com/docker-hub/builds/advanced/#override-build-test-or-push-commands
|
99
README.md
99
README.md
@ -1,22 +1,19 @@
|
|||||||
# netbox-docker
|
# netbox-docker
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/ninech/netbox-docker.svg?branch=master)][travis]
|
This repository houses the components needed to build Netbox as a Docker container.
|
||||||
|
|
||||||
This repository houses the components needed to build NetBox as a Docker container.
|
|
||||||
Images built using this code are released to [Docker Hub][netbox-dockerhub] every night.
|
Images built using this code are released to [Docker Hub][netbox-dockerhub] every night.
|
||||||
|
|
||||||
Questions? Before opening an issue on Github, please join the [Network To Code][ntc-slack] and ask for help in our `#netbox-docker` channel.
|
Questions? Before opening an issue on Github, please join the [Network To Code][ntc-slack] and ask for help in our `#netbox-docker` channel.
|
||||||
|
|
||||||
[travis]: https://travis-ci.org/ninech/netbox-docker
|
[netbox-dockerhub]: https://hub.docker.com/r/netboxcommunity/netbox/tags/
|
||||||
[netbox-dockerhub]: https://hub.docker.com/r/ninech/netbox/tags/
|
|
||||||
[ntc-slack]: http://slack.networktocode.com/
|
[ntc-slack]: http://slack.networktocode.com/
|
||||||
|
|
||||||
## Quickstart
|
## Quickstart
|
||||||
|
|
||||||
To get NetBox up and running:
|
To get Netbox up and running:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ git clone -b master https://github.com/ninech/netbox-docker.git
|
$ git clone -b master https://github.com/netbox-community/netbox-docker.git
|
||||||
$ cd netbox-docker
|
$ cd netbox-docker
|
||||||
$ docker-compose pull
|
$ docker-compose pull
|
||||||
$ docker-compose up -d
|
$ docker-compose up -d
|
||||||
@ -44,7 +41,7 @@ Default credentials:
|
|||||||
* Password: **admin**
|
* Password: **admin**
|
||||||
* API Token: **0123456789abcdef0123456789abcdef01234567**
|
* API Token: **0123456789abcdef0123456789abcdef01234567**
|
||||||
|
|
||||||
[docker-reception]: https://github.com/ninech/reception
|
[docker-reception]: https://github.com/nxt-engineering/reception
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
@ -63,9 +60,9 @@ Read [Environment Variables in Compose][compose-env] to understand about the var
|
|||||||
(The easiest solution being simply adjusting that file.)
|
(The easiest solution being simply adjusting that file.)
|
||||||
|
|
||||||
To find all possible variables, have a look at the [configuration.docker.py][docker-config] and [docker-entrypoint.sh][entrypoint] files.
|
To find all possible variables, have a look at the [configuration.docker.py][docker-config] and [docker-entrypoint.sh][entrypoint] files.
|
||||||
Generally, the environment variables are called the same as their respective NetBox configuration variables.
|
Generally, the environment variables are called the same as their respective Netbox configuration variables.
|
||||||
Variables which are arrays are usually composed by putting all the values into the same environment variables with the values separated by a whitespace ("` `").
|
Variables which are arrays are usually composed by putting all the values into the same environment variables with the values separated by a whitespace ("` `").
|
||||||
For example defining `ALLOWED_HOSTS=localhost ::1 127.0.0.1` would allows access to NetBox through `http://localhost:8080`, `http://[::1]:8080` and `http://127.0.0.1:8080`.
|
For example defining `ALLOWED_HOSTS=localhost ::1 127.0.0.1` would allows access to Netbox through `http://localhost:8080`, `http://[::1]:8080` and `http://127.0.0.1:8080`.
|
||||||
|
|
||||||
[compose-env]: https://docs.docker.com/compose/environment-variables/
|
[compose-env]: https://docs.docker.com/compose/environment-variables/
|
||||||
|
|
||||||
@ -74,7 +71,7 @@ For example defining `ALLOWED_HOSTS=localhost ::1 127.0.0.1` would allows access
|
|||||||
The default settings are optimized for (local) development environments.
|
The default settings are optimized for (local) development environments.
|
||||||
You should therefore adjust the configuration for production setups, at least the following variables:
|
You should therefore adjust the configuration for production setups, at least the following variables:
|
||||||
|
|
||||||
* `ALLOWED_HOSTS`: Add all URLs that lead to your NetBox instance, space separated. E.g. `ALLOWED_HOSTS=netbox.mycorp.com server042.mycorp.com 2a02:123::42 10.0.0.42 localhost ::1 127.0.0.1` (It's good advice to always allow localhost connections for easy debugging, i.e. `localhost ::1 127.0.0.1`.)
|
* `ALLOWED_HOSTS`: Add all URLs that lead to your Netbox instance, space separated. E.g. `ALLOWED_HOSTS=netbox.mycorp.com server042.mycorp.com 2a02:123::42 10.0.0.42 localhost ::1 127.0.0.1` (It's good advice to always allow localhost connections for easy debugging, i.e. `localhost ::1 127.0.0.1`.)
|
||||||
* `DB_*`: Use your own persistent database. Don't use the default passwords!
|
* `DB_*`: Use your own persistent database. Don't use the default passwords!
|
||||||
* `EMAIL_*`: Use your own mailserver.
|
* `EMAIL_*`: Use your own mailserver.
|
||||||
* `MAX_PAGE_SIZE`: Use the recommended default of 1000.
|
* `MAX_PAGE_SIZE`: Use the recommended default of 1000.
|
||||||
@ -85,7 +82,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.
|
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/config/` 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].
|
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.
|
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.
|
||||||
@ -102,11 +99,11 @@ If a secret is defined by an environment variable and in the respective file at
|
|||||||
* `NAPALM_PASSWORD`: `/run/secrets/napalm_password`
|
* `NAPALM_PASSWORD`: `/run/secrets/napalm_password`
|
||||||
* `REDIS_PASSWORD`: `/run/secrets/redis_password`
|
* `REDIS_PASSWORD`: `/run/secrets/redis_password`
|
||||||
|
|
||||||
Please also consider [the advice about running NetBox in production](#production) above!
|
Please also consider [the advice about running Netbox in production](#production) above!
|
||||||
|
|
||||||
[docker-config]: https://github.com/ninech/netbox-docker/blob/master/docker/configuration.docker.py
|
[docker-config]: https://github.com/netbox-community/netbox-docker/blob/master/docker/configuration.docker.py
|
||||||
[default-config]: https://github.com/digitalocean/netbox/blob/develop/netbox/netbox/configuration.example.py
|
[default-config]: https://github.com/digitalocean/netbox/blob/develop/netbox/netbox/configuration.example.py
|
||||||
[entrypoint]: https://github.com/ninech/netbox-docker/blob/master/docker/docker-entrypoint.sh
|
[entrypoint]: https://github.com/netbox-community/netbox-docker/blob/master/docker/docker-entrypoint.sh
|
||||||
[swarm-config]: https://docs.docker.com/engine/swarm/configs/
|
[swarm-config]: https://docs.docker.com/engine/swarm/configs/
|
||||||
[swarm-secrets]: https://docs.docker.com/engine/swarm/secrets/
|
[swarm-secrets]: https://docs.docker.com/engine/swarm/secrets/
|
||||||
[openshift-config]: https://docs.openshift.org/latest/dev_guide/configmaps.html
|
[openshift-config]: https://docs.openshift.org/latest/dev_guide/configmaps.html
|
||||||
@ -116,9 +113,9 @@ Please also consider [the advice about running NetBox in production](#production
|
|||||||
|
|
||||||
### NAPALM Configuration
|
### NAPALM Configuration
|
||||||
|
|
||||||
Since v2.1.0 NAPALM has been tightly integrated into NetBox.
|
Since v2.1.0 NAPALM has been tightly integrated into Netbox.
|
||||||
NAPALM allows NetBox to fetch live data from devices and return it to a requester via its REST API.
|
NAPALM allows Netbox to fetch live data from devices and return it to a requester via its REST API.
|
||||||
To learn more about what NAPALM is and how it works, please see the documentation from the [libary itself][napalm-doc] or the documentation from [NetBox][netbox-napalm-doc] on how it is integrated.
|
To learn more about what NAPALM is and how it works, please see the documentation from the [libary itself][napalm-doc] or the documentation from [Netbox][netbox-napalm-doc] on how it is integrated.
|
||||||
|
|
||||||
To enable this functionality, simply complete the following lines in `netbox.env` (or appropriate secrets mechanism) :
|
To enable this functionality, simply complete the following lines in `netbox.env` (or appropriate secrets mechanism) :
|
||||||
|
|
||||||
@ -133,13 +130,13 @@ However, if you don't need this functionality, leave these blank.
|
|||||||
|
|
||||||
### Customizable Reporting
|
### Customizable Reporting
|
||||||
|
|
||||||
NetBox includes [customized reporting][netbox-reports-doc] that allows the user to write Python code and determine the validity of the data within NetBox.
|
Netbox includes [customized reporting][netbox-reports-doc] that allows the user to write Python code and determine the validity of the data within Netbox.
|
||||||
The `REPORTS_ROOT` variable is setup as a mapped directory within this Docker container to `/reports/` and includes the example directly from the documentation for `devices.py`.
|
The `REPORTS_ROOT` variable is setup as a mapped directory within this Docker container to `/reports/` and includes the example directly from the documentation for `devices.py`.
|
||||||
However, it has been renamed to `devices.py.example` which prevents NetBox from recognizing it as a valid report.
|
However, it has been renamed to `devices.py.example` which prevents Netbox from recognizing it as a valid report.
|
||||||
This was done to avoid unnessary issues from being opened when the default does not work for someone's expectations.
|
This was done to avoid unnessary issues from being opened when the default does not work for someone's expectations.
|
||||||
|
|
||||||
To re-enable this default report, simply rename `devices.py.example` to `devices.py` and browse within the WebUI to `/extras/reports/`.
|
To re-enable this default report, simply rename `devices.py.example` to `devices.py` and browse within the WebUI to `/extras/reports/`.
|
||||||
You can also dynamically add any other report to this same directory and NetBox will be able to see it without restarting the container.
|
You can also dynamically add any other report to this same directory and Netbox will be able to see it without restarting the container.
|
||||||
|
|
||||||
[netbox-reports-doc]: https://netbox.readthedocs.io/en/stable/additional-features/reports/
|
[netbox-reports-doc]: https://netbox.readthedocs.io/en/stable/additional-features/reports/
|
||||||
|
|
||||||
@ -147,7 +144,7 @@ You can also dynamically add any other report to this same directory and NetBox
|
|||||||
|
|
||||||
When using `docker-compose`, all the python scripts present in `/opt/netbox/startup_scripts` will automatically be executed after the application boots in the context of `./manage.py`.
|
When using `docker-compose`, all the python scripts present in `/opt/netbox/startup_scripts` will automatically be executed after the application boots in the context of `./manage.py`.
|
||||||
|
|
||||||
That mechanism can be used for many things, e.g. to create NetBox custom fields:
|
That mechanism can be used for many things, e.g. to create Netbox custom fields:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# docker/startup_scripts/load_custom_fields.py
|
# docker/startup_scripts/load_custom_fields.py
|
||||||
@ -173,7 +170,7 @@ if created:
|
|||||||
|
|
||||||
#### Initializers
|
#### Initializers
|
||||||
|
|
||||||
Initializers are built-in startup scripts for defining NetBox custom fields, groups, users and many other resources.
|
Initializers are built-in startup scripts for defining Netbox custom fields, groups, users and many other resources.
|
||||||
All you need to do is to mount you own `initializers` folder ([see `docker-compose.yml`][netbox-docker-compose]).
|
All you need to do is to mount you own `initializers` folder ([see `docker-compose.yml`][netbox-docker-compose]).
|
||||||
Look at the [`initializers` folder][netbox-docker-initializers] to learn how the files must look like.
|
Look at the [`initializers` folder][netbox-docker-initializers] to learn how the files must look like.
|
||||||
|
|
||||||
@ -197,8 +194,8 @@ text_field:
|
|||||||
- virtualization.models.VirtualMachine
|
- virtualization.models.VirtualMachine
|
||||||
```
|
```
|
||||||
|
|
||||||
[netbox-docker-initializers]: https://github.com/ninech/netbox-docker/tree/master/initializers
|
[netbox-docker-initializers]: https://github.com/netbox-community/netbox-docker/tree/master/initializers
|
||||||
[netbox-docker-compose]: https://github.com/ninech/netbox-docker/blob/master/docker-compose.yml
|
[netbox-docker-compose]: https://github.com/netbox-community/netbox-docker/blob/master/docker-compose.yml
|
||||||
|
|
||||||
##### Available Groups for User/Group initializers
|
##### Available Groups for User/Group initializers
|
||||||
|
|
||||||
@ -211,12 +208,12 @@ echo "from django.contrib.auth.models import Permission\nfor p in Permission.obj
|
|||||||
|
|
||||||
#### Custom Docker Image
|
#### Custom Docker Image
|
||||||
|
|
||||||
You can also build your own NetBox Docker image containing your own startup scripts, custom fields, users and groups
|
You can also build your own Netbox Docker image containing your own startup scripts, custom fields, users and groups
|
||||||
like this:
|
like this:
|
||||||
|
|
||||||
```
|
```
|
||||||
ARG VERSION=latest
|
ARG VERSION=latest
|
||||||
FROM ninech/netbox:$VERSION
|
FROM netboxcommunity/netbox:$VERSION
|
||||||
|
|
||||||
COPY startup_scripts/ /opt/netbox/startup_scripts/
|
COPY startup_scripts/ /opt/netbox/startup_scripts/
|
||||||
COPY initializers/ /opt/netbox/initializers/
|
COPY initializers/ /opt/netbox/initializers/
|
||||||
@ -224,10 +221,10 @@ COPY initializers/ /opt/netbox/initializers/
|
|||||||
|
|
||||||
## Netbox Version
|
## Netbox Version
|
||||||
|
|
||||||
The `docker-compose.yml` file is prepared to run a specific version of NetBox.
|
The `docker-compose.yml` file is prepared to run a specific version of Netbox.
|
||||||
To use this feature, set the environment-variable `VERSION` before launching `docker-compose`, as shown below.
|
To use this feature, set the environment-variable `VERSION` before launching `docker-compose`, as shown below.
|
||||||
`VERSION` may be set to the name of
|
`VERSION` may be set to the name of
|
||||||
[any tag of the `ninech/netbox` Docker image on Docker Hub][netbox-dockerhub].
|
[any tag of the `netboxcommunity/netbox` Docker image on Docker Hub][netbox-dockerhub].
|
||||||
|
|
||||||
```
|
```
|
||||||
$ export VERSION=v2.2.6
|
$ export VERSION=v2.2.6
|
||||||
@ -235,7 +232,7 @@ $ docker-compose pull netbox
|
|||||||
$ docker-compose up -d
|
$ docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also build a specific version of the NetBox image. This time, `VERSION` indicates any valid
|
You can also build a specific version of the Netbox image. This time, `VERSION` indicates any valid
|
||||||
[Git Reference][git-ref] declared on [the 'digitalocean/netbox' Github repository][netbox-github].
|
[Git Reference][git-ref] declared on [the 'digitalocean/netbox' Github repository][netbox-github].
|
||||||
Most commonly you will specify a tag or branch name.
|
Most commonly you will specify a tag or branch name.
|
||||||
|
|
||||||
@ -262,7 +259,7 @@ Custom values can be injected using environment variables, similar to the main c
|
|||||||
This section is a collection of some common issues and how to resolve them.
|
This section is a collection of some common issues and how to resolve them.
|
||||||
If your issue is not here, look through [the existing issues][issues] and eventually create a new issue.
|
If your issue is not here, look through [the existing issues][issues] and eventually create a new issue.
|
||||||
|
|
||||||
[issues]: (https://github.com/ninech/netbox-docker/issues)
|
[issues]: (https://github.com/netbox-community/netbox-docker/issues)
|
||||||
|
|
||||||
### Docker Compose basics
|
### Docker Compose basics
|
||||||
|
|
||||||
@ -271,7 +268,7 @@ If your issue is not here, look through [the existing issues][issues] and eventu
|
|||||||
Running `docker-compose logs -f netbox` will just show the logs for netbox.
|
Running `docker-compose logs -f netbox` will just show the logs for netbox.
|
||||||
* You can stop everything using `docker-compose stop`.
|
* You can stop everything using `docker-compose stop`.
|
||||||
* You can clean up everything using `docker-compose down -v --remove-orphans`. **This will also remove any related data.**
|
* You can clean up everything using `docker-compose down -v --remove-orphans`. **This will also remove any related data.**
|
||||||
* You can enter the shell of the running NetBox container using `docker-compose exec netbox /bin/bash`. Now you have access to `./manage.py`, e.g. to reset a password.
|
* You can enter the shell of the running Netbox container using `docker-compose exec netbox /bin/bash`. Now you have access to `./manage.py`, e.g. to reset a password.
|
||||||
* To access the database run `docker-compose exec postgres sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB'`
|
* To access the database run `docker-compose exec postgres sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB'`
|
||||||
* To create a database backup run `docker-compose exec postgres sh -c 'pg_dump -cU $POSTGRES_USER $POSTGRES_DB' | gzip > db_dump.sql.gz`
|
* To create a database backup run `docker-compose exec postgres sh -c 'pg_dump -cU $POSTGRES_USER $POSTGRES_DB' | gzip > db_dump.sql.gz`
|
||||||
* To restore that database backup run `gunzip -c db_dump.sql.gz | docker exec -i $(docker-compose ps -q postgres) sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB'`.
|
* To restore that database backup run `gunzip -c db_dump.sql.gz | docker exec -i $(docker-compose ps -q postgres) sh -c 'psql -U $POSTGRES_USER $POSTGRES_DB'`.
|
||||||
@ -304,7 +301,7 @@ $ docker-compose logs -f nginx
|
|||||||
|
|
||||||
### Getting a "Bad Request (400)"
|
### Getting a "Bad Request (400)"
|
||||||
|
|
||||||
> When connecting to the NetBox instance, I get a "Bad Request (400)" error.
|
> When connecting to the Netbox instance, I get a "Bad Request (400)" error.
|
||||||
|
|
||||||
This usually happens when the `ALLOWED_HOSTS` variable is not set correctly.
|
This usually happens when the `ALLOWED_HOSTS` variable is not set correctly.
|
||||||
|
|
||||||
@ -375,7 +372,7 @@ If you don't see anything happening after you triggered a webhook, double-check
|
|||||||
From time to time it might become necessary to re-engineer the structure of this setup.
|
From time to time it might become necessary to re-engineer the structure of this setup.
|
||||||
Things like the `docker-compose.yml` file or your Kubernetes or OpenShift configurations have to be adjusted as a consequence.
|
Things like the `docker-compose.yml` file or your Kubernetes or OpenShift configurations have to be adjusted as a consequence.
|
||||||
Since April 2018 each image built from this repo contains a `NETBOX_DOCKER_PROJECT_VERSION` label.
|
Since April 2018 each image built from this repo contains a `NETBOX_DOCKER_PROJECT_VERSION` label.
|
||||||
You can check the label of your local image by running `docker inspect ninech/netbox:v2.3.1 --format "{{json .ContainerConfig.Labels}}"`.
|
You can check the label of your local image by running `docker inspect netboxcommunity/netbox:v2.3.1 --format "{{json .ContainerConfig.Labels}}"`.
|
||||||
Compare the version with the list below to check whether a breaking change was introduced with that version.
|
Compare the version with the list below to check whether a breaking change was introduced with that version.
|
||||||
|
|
||||||
The following is a list of breaking changes of the `netbox-docker` project:
|
The following is a list of breaking changes of the `netbox-docker` project:
|
||||||
@ -386,41 +383,21 @@ The following is a list of breaking changes of the `netbox-docker` project:
|
|||||||
* 0.5.0: Alpine was updated to 3.8, `*.env` moved to `/env` folder
|
* 0.5.0: Alpine was updated to 3.8, `*.env` moved to `/env` folder
|
||||||
* 0.4.0: In order to use Netbox webhooks you need to add Redis and a netbox-worker to your docker-compose.yml.
|
* 0.4.0: In order to use Netbox webhooks you need to add Redis and a netbox-worker to your docker-compose.yml.
|
||||||
* 0.3.0: Field `filterable: <boolean` was replaced with field `filter_logic: loose/exact/disabled`. It will default to `CF_FILTER_LOOSE=loose` when not defined.
|
* 0.3.0: Field `filterable: <boolean` was replaced with field `filter_logic: loose/exact/disabled`. It will default to `CF_FILTER_LOOSE=loose` when not defined.
|
||||||
* 0.2.0: Re-organized paths: `/etc/netbox -> /etc/netbox/config` and `/etc/reports -> /etc/netbox/reports`. Fixes [#54](https://github.com/ninech/netbox-docker/issues/54).
|
* 0.2.0: Re-organized paths: `/etc/netbox -> /etc/netbox/config` and `/etc/reports -> /etc/netbox/reports`. Fixes [#54](https://github.com/netbox-community/netbox-docker/issues/54).
|
||||||
* 0.1.0: Introduction of the `NETBOX_DOCKER_PROJECT_VERSION`. (Not a breaking change per se.)
|
* 0.1.0: Introduction of the `NETBOX_DOCKER_PROJECT_VERSION`. (Not a breaking change per se.)
|
||||||
|
|
||||||
## Rebuilding & Publishing images
|
## Rebuilding & Publishing images
|
||||||
|
|
||||||
`./build.sh` is used to rebuild the Docker image:
|
`./build.sh` can be used to rebuild the Docker image. See `./build.sh --help` for more information.
|
||||||
|
|
||||||
```
|
|
||||||
$ ./build.sh --help
|
|
||||||
Usage: ./build.sh <branch> [--push]
|
|
||||||
branch The branch or tag to build. Required.
|
|
||||||
--push Pushes built Docker image to docker hub.
|
|
||||||
|
|
||||||
You can use the following ENV variables to customize the build:
|
|
||||||
BRANCH The branch to build.
|
|
||||||
Also used for tagging the image.
|
|
||||||
DOCKER_REPO The Docker registry (i.e. hub.docker.com/r/DOCKER_REPO/netbox)
|
|
||||||
Also used for tagging the image.
|
|
||||||
Default: ninech
|
|
||||||
SRC_REPO Which fork of netbox to use (i.e. github.com/<SRC_REPO>/netbox).
|
|
||||||
Default: digitalocean
|
|
||||||
URL Where to fetch the package from.
|
|
||||||
Must be a tar.gz file of the source code.
|
|
||||||
Default: https://github.com/${SRC_REPO}/netbox/archive/$BRANCH.tar.gz
|
|
||||||
```
|
|
||||||
|
|
||||||
### Publishing Docker Images
|
### Publishing Docker Images
|
||||||
|
|
||||||
New Docker Images are built and published every 24h by using travis:
|
New Docker Images are built and published every 24h on the [Docker Build Infrastructure](https://hub.docker.com/r/netboxcommunity/netbox/builds/).
|
||||||
|
`DOCKER_HUB.md` contains more information about the build infrastructure.
|
||||||
[![Build Status](https://travis-ci.org/ninech/netbox-docker.svg?branch=master)][travis]
|
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
To run the tests coming with NetBox, use the `docker-compose.yml` file as such:
|
To run the tests coming with Netbox, use the `docker-compose.yml` file as such:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ docker-compose run netbox ./manage.py test
|
$ docker-compose run netbox ./manage.py test
|
||||||
@ -428,6 +405,4 @@ $ docker-compose run netbox ./manage.py test
|
|||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
||||||
This repository is currently maintained and funded by [nine](https://nine.ch), your cloud navigator.
|
This repository is currently maintained and funded by [nxt](https://nxt.engineering).
|
||||||
|
|
||||||
[![logo of the company 'nine'](https://logo.apps.at-nine.ch/Dmqied_eSaoBMQwk3vVgn4UIgDo=/trim/500x0/logo_claim.png)](https://www.nine.ch)
|
|
||||||
|
16
build-all.sh
16
build-all.sh
@ -12,9 +12,9 @@ BUILDS=("${BUILD:-"${ALL_BUILDS[@]}"}")
|
|||||||
|
|
||||||
echo "⚙️ Configured builds: ${BUILDS[*]}"
|
echo "⚙️ Configured builds: ${BUILDS[*]}"
|
||||||
|
|
||||||
VARIANTS=("" "ldap")
|
VARIANTS=("main" "ldap")
|
||||||
|
|
||||||
if [ ! -z "${DEBUG}" ]; then
|
if [ -n "${DEBUG}" ]; then
|
||||||
export DEBUG
|
export DEBUG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -22,16 +22,14 @@ ERROR=0
|
|||||||
|
|
||||||
# Don't build if not on `master` and don't build if on a pull request,
|
# Don't build if not on `master` and don't build if on a pull request,
|
||||||
# but build when DEBUG is not empty
|
# but build when DEBUG is not empty
|
||||||
if [ ! -z "${DEBUG}" ] || \
|
|
||||||
( [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] ); then
|
|
||||||
for VARIANT in "${VARIANTS[@]}"; do
|
for VARIANT in "${VARIANTS[@]}"; do
|
||||||
export VARIANT
|
export VARIANT
|
||||||
|
|
||||||
# Checking which VARIANT to build
|
# Checking which VARIANT to build
|
||||||
if [ -z "$VARIANT" ]; then
|
if [ "${VARIANT}" == "main" ]; then
|
||||||
DOCKERFILE="Dockerfile"
|
DOCKERFILE="${DOCKERFILE_PATH-Dockerfile}"
|
||||||
else
|
else
|
||||||
DOCKERFILE="Dockerfile.${VARIANT}"
|
DOCKERFILE="${DOCKERFILE_PATH-Dockerfile}.${VARIANT}"
|
||||||
|
|
||||||
# Fail fast
|
# Fail fast
|
||||||
if [ ! -f "${DOCKERFILE}" ]; then
|
if [ ! -f "${DOCKERFILE}" ]; then
|
||||||
@ -68,6 +66,7 @@ if [ ! -z "${DEBUG}" ] || \
|
|||||||
# special build
|
# special build
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
#SRC_ORG=lampwins TAG=webhooks-backend ./build.sh "feature/webhooks-backend" $@ || ERROR=1
|
#SRC_ORG=lampwins TAG=webhooks-backend ./build.sh "feature/webhooks-backend" $@ || ERROR=1
|
||||||
|
echo "✅ No special builds today."
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "🚨 Unrecognized build '$BUILD'."
|
echo "🚨 Unrecognized build '$BUILD'."
|
||||||
@ -81,8 +80,5 @@ if [ ! -z "${DEBUG}" ] || \
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
else
|
|
||||||
echo "❎ Not building anything."
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit $ERROR
|
exit $ERROR
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
echo "▶️ $0 $*"
|
echo "▶️ $0 $*"
|
||||||
|
|
||||||
if [ ! -z "${GITHUB_OAUTH_CLIENT_ID}" ] && [ ! -z "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then
|
if [ -n "${GITHUB_OAUTH_CLIENT_ID}" ] && [ -n "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then
|
||||||
echo "🗝 Performing authenticated Github API calls."
|
echo "🗝 Performing authenticated Github API calls."
|
||||||
GITHUB_OAUTH_PARAMS="client_id=${GITHUB_OAUTH_CLIENT_ID}&client_secret=${GITHUB_OAUTH_CLIENT_SECRET}"
|
GITHUB_OAUTH_PARAMS="client_id=${GITHUB_OAUTH_CLIENT_ID}&client_secret=${GITHUB_OAUTH_CLIENT_SECRET}"
|
||||||
else
|
else
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
echo "▶️ $0 $*"
|
echo "▶️ $0 $*"
|
||||||
|
|
||||||
if [ ! -z "${GITHUB_OAUTH_CLIENT_ID}" ] && [ ! -z "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then
|
if [ -n "${GITHUB_OAUTH_CLIENT_ID}" ] && [ -n "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then
|
||||||
echo "🗝 Performing authenticated Github API calls."
|
echo "🗝 Performing authenticated Github API calls."
|
||||||
GITHUB_OAUTH_PARAMS="client_id=${GITHUB_OAUTH_CLIENT_ID}&client_secret=${GITHUB_OAUTH_CLIENT_SECRET}"
|
GITHUB_OAUTH_PARAMS="client_id=${GITHUB_OAUTH_CLIENT_ID}&client_secret=${GITHUB_OAUTH_CLIENT_SECRET}"
|
||||||
else
|
else
|
||||||
|
16
build.sh
16
build.sh
@ -6,9 +6,10 @@ echo "▶️ $0 $*"
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ "${1}x" == "x" ] || [ "${1}" == "--help" ] || [ "${1}" == "-h" ]; then
|
if [ "${1}x" == "x" ] || [ "${1}" == "--help" ] || [ "${1}" == "-h" ]; then
|
||||||
echo "Usage: ${0} <branch> [--push]"
|
echo "Usage: ${0} <branch> [--push|--push-only]"
|
||||||
echo " branch The branch or tag to build. Required."
|
echo " branch The branch or tag to build. Required."
|
||||||
echo " --push Pushes built Docker image to docker hub."
|
echo " --push Pushes built the Docker image to the registry."
|
||||||
|
echo " --push-only Does not build. Only pushes the Docker image to the registry."
|
||||||
echo ""
|
echo ""
|
||||||
echo "You can use the following ENV variables to customize the build:"
|
echo "You can use the following ENV variables to customize the build:"
|
||||||
echo " DEBUG If defined, the script does not stop when certain checks are unsatisfied."
|
echo " DEBUG If defined, the script does not stop when certain checks are unsatisfied."
|
||||||
@ -49,8 +50,9 @@ if [ "${1}x" == "x" ] || [ "${1}" == "--help" ] || [ "${1}" == "-h" ]; then
|
|||||||
echo " ARG FROM_TAG=latest"
|
echo " ARG FROM_TAG=latest"
|
||||||
echo " FROM \$DOCKER_ORG/\$DOCKER_REPO:\$FROM_TAG"
|
echo " FROM \$DOCKER_ORG/\$DOCKER_REPO:\$FROM_TAG"
|
||||||
echo " Example: VARIANT=ldap will result in the tag 'latest-ldap' and the"
|
echo " Example: VARIANT=ldap will result in the tag 'latest-ldap' and the"
|
||||||
echo " Dockerfile 'Dockerfile.ldap' being used."
|
echo " Dockerfile './Dockerfile.ldap' being used."
|
||||||
echo " Default: empty"
|
echo " Exception: VARIANT=main will use the './Dockerfile' Dockerfile"
|
||||||
|
echo " Default: main"
|
||||||
echo " HTTP_PROXY The proxy to use for http requests."
|
echo " HTTP_PROXY The proxy to use for http requests."
|
||||||
echo " Example: http://proxy.domain.tld:3128"
|
echo " Example: http://proxy.domain.tld:3128"
|
||||||
echo " Default: empty"
|
echo " Default: empty"
|
||||||
@ -95,7 +97,7 @@ esac
|
|||||||
DOCKER_TAG="${DOCKER_TAG-${DOCKER_ORG}/${DOCKER_REPO}:${TAG}}"
|
DOCKER_TAG="${DOCKER_TAG-${DOCKER_ORG}/${DOCKER_REPO}:${TAG}}"
|
||||||
|
|
||||||
# Checking which VARIANT to build
|
# Checking which VARIANT to build
|
||||||
if [ -z "$VARIANT" ]; then
|
if [ "$VARIANT" == "main" ]; then
|
||||||
DOCKERFILE="Dockerfile"
|
DOCKERFILE="Dockerfile"
|
||||||
else
|
else
|
||||||
DOCKERFILE="Dockerfile.${VARIANT}"
|
DOCKERFILE="Dockerfile.${VARIANT}"
|
||||||
@ -152,11 +154,13 @@ else
|
|||||||
DOCKER_CMD="echo docker"
|
DOCKER_CMD="echo docker"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${2}" != "--push-only" ] ; then
|
||||||
echo "🐳 Building the Docker image '${DOCKER_TAG}' from the url '${URL}'."
|
echo "🐳 Building the Docker image '${DOCKER_TAG}' from the url '${URL}'."
|
||||||
$DOCKER_CMD build -t "${DOCKER_TAG}" "${DOCKER_BUILD_ARGS[@]}" "${DOCKER_OPTS[@]}" -f "${DOCKERFILE}" .
|
$DOCKER_CMD build -t "${DOCKER_TAG}" "${DOCKER_BUILD_ARGS[@]}" "${DOCKER_OPTS[@]}" -f "${DOCKERFILE}" .
|
||||||
echo "✅ Finished building the Docker images '${DOCKER_TAG}'"
|
echo "✅ Finished building the Docker images '${DOCKER_TAG}'"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${2}" == "--push" ] ; then
|
if [ "${2}" == "--push" ] || [ "${2}" == "--push-only" ] ; then
|
||||||
echo "⏫ Pushing '${DOCKER_TAG}"
|
echo "⏫ Pushing '${DOCKER_TAG}"
|
||||||
$DOCKER_CMD push "${DOCKER_TAG}"
|
$DOCKER_CMD push "${DOCKER_TAG}"
|
||||||
echo "✅ Finished pushing the Docker image '${DOCKER_TAG}'."
|
echo "✅ Finished pushing the Docker image '${DOCKER_TAG}'."
|
||||||
|
5
hooks/build
Executable file
5
hooks/build
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. hooks/common
|
||||||
|
|
||||||
|
run_build
|
82
hooks/common
Executable file
82
hooks/common
Executable file
@ -0,0 +1,82 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ensure_jq() {
|
||||||
|
echo "🛠🛠🛠 Installing JQ via apt-get"
|
||||||
|
[ -x "$(command -v jq)" ] || ( apt-get update && apt-get install -y jq )
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_dockerfile_present() {
|
||||||
|
if [ "${VARIANT}" == "main" ]; then
|
||||||
|
DOCKERFILE="Dockerfile"
|
||||||
|
else
|
||||||
|
DOCKERFILE="Dockerfile.${VARIANT}"
|
||||||
|
|
||||||
|
# Fail fast
|
||||||
|
if [ ! -f "${DOCKERFILE}" ]; then
|
||||||
|
echo "🚨 The Dockerfile '${DOCKERFILE}' for variant '${VARIANT}' doesn't exist."
|
||||||
|
|
||||||
|
if [ -z "$DEBUG" ]; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "⚠️ Would skip this, but DEBUG is enabled."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${DOCKERFILE}" != "${DOCKERFILE_PATH}" ]; then
|
||||||
|
echo "⚠️ The specified Dockerfile '${DOCKERFILE_PATH}' does not match the expected Dockerfile '${DOCKERFILE}'."
|
||||||
|
echo " This script will use '${DOCKERFILE}' and ignore '${DOCKERFILE_PATH}'."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Passes args to the scripts
|
||||||
|
run_build() {
|
||||||
|
echo "🐳🐳🐳 Building '${BUILD}' images, the '${VARIANT:-main}' variant"
|
||||||
|
case $BUILD in
|
||||||
|
release)
|
||||||
|
# build the latest release
|
||||||
|
# shellcheck disable=SC2068
|
||||||
|
./build-latest.sh $@
|
||||||
|
;;
|
||||||
|
prerelease)
|
||||||
|
# build the latest pre-release
|
||||||
|
# shellcheck disable=SC2068
|
||||||
|
PRERELEASE=true ./build-latest.sh $@
|
||||||
|
;;
|
||||||
|
branches)
|
||||||
|
# build all branches
|
||||||
|
# shellcheck disable=SC2068
|
||||||
|
./build-branches.sh $@
|
||||||
|
;;
|
||||||
|
special)
|
||||||
|
# special build
|
||||||
|
# shellcheck disable=SC2068
|
||||||
|
#SRC_ORG=lampwins TAG=webhooks-backend ./build.sh "feature/webhooks-backend" $@
|
||||||
|
echo "✅ No special builds today."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "🚨 Unrecognized build '$BUILD'."
|
||||||
|
|
||||||
|
if [ -z "$DEBUG" ]; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "⚠️ Would exit here with code '1', but DEBUG is enabled."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "🤖🤖🤖 Preparing build"
|
||||||
|
export DOCKER_ORG="index.docker.io/cimnine"
|
||||||
|
export DOCKER_REPO=netbox-test
|
||||||
|
export DOCKERHUB_REPO=cimnine/netbox-test
|
||||||
|
|
||||||
|
# mis-using the "${DOCKER_TAG}" variable as "branch to build"
|
||||||
|
export BUILD="${DOCKER_TAG%-*}"
|
||||||
|
export VARIANT="${DOCKER_TAG#*-}"
|
||||||
|
|
||||||
|
unset DOCKER_TAG
|
||||||
|
|
||||||
|
ensure_dockerfile_present
|
||||||
|
|
||||||
|
ensure_jq
|
5
hooks/push
Executable file
5
hooks/push
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. hooks/common
|
||||||
|
|
||||||
|
run_build --push-only
|
12
hooks/test
Executable file
12
hooks/test
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. hooks/common
|
||||||
|
|
||||||
|
if [ "${VARIANT}" == "main" ] && [ "${BUILD}" == "BRANCHES" ]; then
|
||||||
|
echo "🐳🐳🐳 Testing"
|
||||||
|
docker-compose pull --parallel
|
||||||
|
docker-compose build
|
||||||
|
docker-compose run netbox ./manage.py test
|
||||||
|
else
|
||||||
|
echo "🐳🐳🐳 No tests are implemented for build '${BUILD}' with variant '${VARIANT}'."
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user