Merge branch 'labelling'
This commit is contained in:
commit
52d67f6b60
|
@ -45,12 +45,22 @@ The output of `docker version`: `XXXXX`
|
|||
The output of `git rev-parse HEAD`: `XXXXX`
|
||||
The command you used to start the project: `XXXXX`
|
||||
|
||||
<!-- adjust the `latest` tag to the version you're using -->
|
||||
The output of `docker inspect netboxcommunity/netbox:latest --format "{{json .ContainerConfig.Labels}}"`:
|
||||
|
||||
```json
|
||||
{
|
||||
"JSON JSON JSON":
|
||||
"--> Please paste formatted json. (Use e.g. `jq` or https://jsonformatter.curiousconcept.com/)"
|
||||
}
|
||||
```
|
||||
|
||||
The output of `docker-compose logs netbox`:
|
||||
<!--
|
||||
If your log is very long, create a Gist instead (and post the link to it): https://gist.github.com
|
||||
-->
|
||||
|
||||
```
|
||||
```text
|
||||
LOG LOG LOG
|
||||
```
|
||||
|
||||
|
@ -60,6 +70,6 @@ Only if you have gotten a 5xx http error, else delete this section.
|
|||
If your log is very long, create a Gist instead (and post the link to it): https://gist.github.com
|
||||
-->
|
||||
|
||||
```
|
||||
```text
|
||||
LOG LOG LOG
|
||||
```
|
||||
|
|
33
Dockerfile
33
Dockerfile
|
@ -72,11 +72,34 @@ ENTRYPOINT [ "/opt/netbox/docker-entrypoint.sh" ]
|
|||
|
||||
CMD ["gunicorn", "-c /etc/netbox/config/gunicorn_config.py", "netbox.wsgi"]
|
||||
|
||||
LABEL NETBOX_DOCKER_PROJECT_VERSION="custom build" \
|
||||
NETBOX_BRANCH="custom build" \
|
||||
ORIGINAL_DOCKER_TAG="custom build" \
|
||||
NETBOX_GIT_COMMIT="not built from git" \
|
||||
NETBOX_GIT_URL="not built from git"
|
||||
LABEL ORIGINAL_TAG="" \
|
||||
NETBOX_GIT_BRANCH="" \
|
||||
NETBOX_GIT_REF="" \
|
||||
NETBOX_GIT_URL="" \
|
||||
# See http://label-schema.org/rc1/#build-time-labels
|
||||
# Also https://microbadger.com/labels
|
||||
org.label-schema.schema-version="1.0" \
|
||||
org.label-schema.build-date="" \
|
||||
org.label-schema.name="Netbox Docker" \
|
||||
org.label-schema.description="A container based distribution of Netbox, the free and open IPAM and DCIM solution." \
|
||||
org.label-schema.vendor="The netbox-docker contributors." \
|
||||
org.label-schema.url="https://github.com/netbox-community/netbox-docker" \
|
||||
org.label-schema.usage="https://github.com/netbox-community/netbox-docker/wiki" \
|
||||
org.label-schema.vcs-url="https://github.com/netbox-community/netbox-docker.git" \
|
||||
org.label-schema.vcs-ref="" \
|
||||
org.label-schema.version="snapshot" \
|
||||
# See https://github.com/opencontainers/image-spec/blob/master/annotations.md#pre-defined-annotation-keys
|
||||
org.opencontainers.image.created="" \
|
||||
org.opencontainers.image.title="Netbox Docker" \
|
||||
org.opencontainers.image.description="A container based distribution of Netbox, the free and open IPAM and DCIM solution." \
|
||||
org.opencontainers.image.licenses="Apache-2.0" \
|
||||
org.opencontainers.image.authors="The netbox-docker contributors." \
|
||||
org.opencontainers.image.vendor="The netbox-docker contributors." \
|
||||
org.opencontainers.image.url="https://github.com/netbox-community/netbox-docker" \
|
||||
org.opencontainers.image.documentation="https://github.com/netbox-community/netbox-docker/wiki" \
|
||||
org.opencontainers.image.source="https://github.com/netbox-community/netbox-docker.git" \
|
||||
org.opencontainers.image.revision="" \
|
||||
org.opencontainers.image.version="snapshot"
|
||||
|
||||
#####
|
||||
## LDAP specific configuration
|
||||
|
|
46
README.md
46
README.md
|
@ -1,14 +1,45 @@
|
|||
# netbox-docker
|
||||
|
||||
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/netbox-community/netbox-docker)][github-release]
|
||||
[![GitHub stars](https://img.shields.io/github/stars/netbox-community/netbox-docker)][github-stargazers]
|
||||
![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed-raw/netbox-community/netbox-docker)
|
||||
![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/netboxcommunity/netbox)
|
||||
![Docker Pulls](https://img.shields.io/docker/pulls/netboxcommunity/netbox)
|
||||
[![MicroBadger Layers](https://img.shields.io/microbadger/layers/netboxcommunity/netbox)][netbox-docker-microbadger]
|
||||
[![MicroBadger Size](https://img.shields.io/microbadger/image-size/netboxcommunity/netbox)][netbox-docker-microbadger]
|
||||
[![GitHub license](https://img.shields.io/github/license/netbox-community/netbox-docker)][netbox-docker-license]
|
||||
|
||||
[The Github repository](netbox-docker-github) houses the components needed to build Netbox as a Docker container.
|
||||
Images are built using this code and are released to [Docker Hub][netbox-dockerhub] once a day.
|
||||
|
||||
Do you have any questions? Before opening an issue on Github, please join the [Network To Code][ntc-slack] Slack and ask for help in our [`#netbox-docker`][netbox-docker-slack] channel.
|
||||
|
||||
[github-stargazers]: https://github.com/netbox-community/netbox-docker/stargazers
|
||||
[github-release]: https://github.com/netbox-community/netbox-docker/releases
|
||||
[netbox-docker-microbadger]: https://microbadger.com/images/netboxcommunity/netbox
|
||||
[netbox-dockerhub]: https://hub.docker.com/r/netboxcommunity/netbox/tags/
|
||||
[netbox-docker-github]: https://github.com/netbox-community/netbox-docker/
|
||||
[ntc-slack]: http://slack.networktocode.com/
|
||||
[netbox-docker-slack]: https://slack.com/app_redirect?channel=netbox-docker&team=T09LQ7E9E
|
||||
[netbox-docker-license]: https://github.com/netbox-community/netbox-docker/blob/master/LICENSE
|
||||
|
||||
## Docker Tags
|
||||
|
||||
* `vX.Y.Z`: Release builds, built from [releases of Netbox][netbox-releases].
|
||||
* `latest`: Release builds, built from [`master` branch of Netbox][netbox-master].
|
||||
* `snapshot`: Pre-release builds, built from the [`develop` branch of Netbox][netbox-develop].
|
||||
* `develop-X.Y`: Pre-release builds, built from the corresponding [branch of Netbox][netbox-branches].
|
||||
|
||||
Then there is currently one extra tags for each of the above labels:
|
||||
|
||||
* `-ldap`: Contains additional dependencies and configurations for connecting Netbox to an LDAP directroy.
|
||||
[Learn more about that in our wiki][netbox-docker-ldap].
|
||||
|
||||
[netbox-releases]: https://github.com/netbox-community/netbox/releases
|
||||
[netbox-master]: https://github.com/netbox-community/netbox/tree/master
|
||||
[netbox-develop]: https://github.com/netbox-community/netbox/tree/develop
|
||||
[netbox-branches]: https://github.com/netbox-community/netbox/branches
|
||||
[netbox-docker-ldap]: https://github.com/netbox-community/netbox-docker/wiki/LDAP
|
||||
|
||||
## Quickstart
|
||||
|
||||
|
@ -54,12 +85,12 @@ This project relies only on *Docker* and *docker-compose* meeting this requireme
|
|||
|
||||
To ensure this, compare the output of `docker --version` and `docker-compose --version` with the requirements above.
|
||||
|
||||
## Reference Documentation
|
||||
## Documentation
|
||||
|
||||
Please refer [to the wiki][wiki] for further information on how to use this Netbox Docker image properly.
|
||||
Please refer [to our wiki on Github][netbox-docker-wiki] for further information on how to use this Netbox Docker image properly.
|
||||
It covers advanced topics such as using secret files, deployment to Kubernetes as well as NAPALM and LDAP configuration.
|
||||
|
||||
[wiki]: https://github.com/netbox-community/netbox-docker/wiki/
|
||||
[netbox-docker-wiki]: https://github.com/netbox-community/netbox-docker/wiki/
|
||||
|
||||
## Netbox Version
|
||||
|
||||
|
@ -69,7 +100,7 @@ To use this feature, set the environment-variable `VERSION` before launching `do
|
|||
[any tag of the `netboxcommunity/netbox` Docker image on Docker Hub][netbox-dockerhub].
|
||||
|
||||
```bash
|
||||
export VERSION=v2.6.6
|
||||
export VERSION=v2.6.7
|
||||
docker-compose pull netbox
|
||||
docker-compose up -d
|
||||
```
|
||||
|
@ -78,7 +109,7 @@ You can also build a specific version of the Netbox Docker image yourself.
|
|||
`VERSION` can be any valid [git ref][git-ref] in that case.
|
||||
|
||||
```bash
|
||||
export VERSION=v2.6.6
|
||||
export VERSION=v2.6.7
|
||||
./build.sh $VERSION
|
||||
docker-compose up -d
|
||||
```
|
||||
|
@ -90,8 +121,9 @@ docker-compose up -d
|
|||
|
||||
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.
|
||||
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 netboxcommunity/netbox:v2.3.1 --format "{{json .ContainerConfig.Labels}}"`.
|
||||
Since November 2019 each image built from this repo contains a `org.opencontainers.image.version` label.
|
||||
(The images contained labels since April 2018, although in November 2019 the labels' names changed.)
|
||||
You can check the label of your local image by running `docker inspect netboxcommunity/netbox:v2.6.7 --format "{{json .ContainerConfig.Labels}}"`.
|
||||
|
||||
Please read [the release notes][releases] carefully when updating to a new image version.
|
||||
|
||||
|
|
95
build.sh
95
build.sh
|
@ -30,23 +30,26 @@ if [ "${1}x" == "x" ] || [ "${1}" == "--help" ] || [ "${1}" == "-h" ]; then
|
|||
echo " When \${BRANCH}=master: latest"
|
||||
echo " When \${BRANCH}=develop: snapshot"
|
||||
echo " Else: same as \${BRANCH}"
|
||||
echo " DOCKER_ORG The Docker registry (i.e. hub.docker.com/r/\${DOCKER_ORG}/\${DOCKER_REPO})"
|
||||
echo " Also used for tagging the image."
|
||||
echo " DOCKER_REGISTRY The Docker repository's registry (i.e. '\${DOCKER_REGISTRY}/\${DOCKER_ORG}/\${DOCKER_REPO}'')"
|
||||
echo " Used for tagging the image."
|
||||
echo " Default: docker.io"
|
||||
echo " DOCKER_ORG The Docker repository's organisation (i.e. '\${DOCKER_REGISTRY}/\${DOCKER_ORG}/\${DOCKER_REPO}'')"
|
||||
echo " Used for tagging the image."
|
||||
echo " Default: netboxcommunity"
|
||||
echo " DOCKER_REPO The Docker registry (i.e. hub.docker.com/r/\${DOCKER_ORG}/\${DOCKER_REPO})"
|
||||
echo " Also used for tagging the image."
|
||||
echo " DOCKER_REPO The Docker repository's name (i.e. '\${DOCKER_REGISTRY}/\${DOCKER_ORG}/\${DOCKER_REPO}'')"
|
||||
echo " Used for tagging the image."
|
||||
echo " Default: netbox"
|
||||
echo " DOCKER_FROM The base image to use."
|
||||
echo " Default: Whatever is defined as default in the Dockerfile."
|
||||
echo " DOCKER_TAG The name of the tag which is applied to the image."
|
||||
echo " Useful for pushing into another registry than hub.docker.com."
|
||||
echo " Default: \${DOCKER_ORG}/\${DOCKER_REPO}:\${TAG}"
|
||||
echo " Default: \${DOCKER_REGISTRY}/\${DOCKER_ORG}/\${DOCKER_REPO}:\${TAG}"
|
||||
echo " DOCKER_SHORT_TAG The name of the short tag which is applied to the"
|
||||
echo " image. This is used to tag all patch releases to their"
|
||||
echo " containing version e.g. v2.5.1 -> v2.5"
|
||||
echo " Default: \${DOCKER_ORG}/\${DOCKER_REPO}:<MAJOR>.<MINOR>"
|
||||
echo " Default: \${DOCKER_REGISTRY}/\${DOCKER_ORG}/\${DOCKER_REPO}:<MAJOR>.<MINOR>"
|
||||
echo " DOCKERFILE The name of Dockerfile to use."
|
||||
echo " Default: Dockerfile"
|
||||
echo " DOCKER_FROM The base image to use."
|
||||
echo " Default: Whatever is defined as default in the Dockerfile."
|
||||
echo " DOCKER_TARGET A specific target to build."
|
||||
echo " It's currently not possible to pass multiple targets."
|
||||
echo " Default: main ldap"
|
||||
|
@ -98,12 +101,6 @@ else
|
|||
DRY="echo"
|
||||
fi
|
||||
|
||||
###
|
||||
# read the project version from the `VERSION` file and trim it
|
||||
# see https://stackoverflow.com/a/3232433/172132
|
||||
###
|
||||
NETBOX_DOCKER_PROJECT_VERSION="${NETBOX_DOCKER_PROJECT_VERSION-$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' VERSION)}"
|
||||
|
||||
###
|
||||
# variables for fetching the source
|
||||
###
|
||||
|
@ -152,9 +149,29 @@ if [ ! -f "${DOCKERFILE}" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
###
|
||||
# variables for labelling the docker image
|
||||
###
|
||||
BUILD_DATE="$(date --utc --iso-8601=minutes)"
|
||||
|
||||
if [ -d ".git" ]; then
|
||||
GIT_REF="$(git rev-parse HEAD)"
|
||||
fi
|
||||
|
||||
# read the project version from the `VERSION` file and trim it, see https://stackoverflow.com/a/3232433/172132
|
||||
PROJECT_VERSION="${PROJECT_VERSION-$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' VERSION)}"
|
||||
|
||||
# Get the Git information from the netbox directory
|
||||
if [ -d "${NETBOX_PATH}/.git" ]; then
|
||||
NETBOX_GIT_REF=$(cd ${NETBOX_PATH}; git rev-parse HEAD)
|
||||
NETBOX_GIT_BRANCH=$(cd ${NETBOX_PATH}; git rev-parse --abbrev-ref HEAD)
|
||||
NETBOX_GIT_URL=$(cd ${NETBOX_PATH}; git remote get-url origin)
|
||||
fi
|
||||
|
||||
###
|
||||
# variables for tagging the docker image
|
||||
###
|
||||
DOCKER_REGISTRY="${DOCKER_REGISTRY-docker.io}"
|
||||
DOCKER_ORG="${DOCKER_ORG-netboxcommunity}"
|
||||
DOCKER_REPO="${DOCKER_REPO-netbox}"
|
||||
case "${BRANCH}" in
|
||||
|
@ -182,7 +199,7 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
|||
###
|
||||
# composing the final TARGET_DOCKER_TAG
|
||||
###
|
||||
TARGET_DOCKER_TAG="${DOCKER_TAG-${DOCKER_ORG}/${DOCKER_REPO}:${TAG}}"
|
||||
TARGET_DOCKER_TAG="${DOCKER_TAG-${DOCKER_REGISTRY}/${DOCKER_ORG}/${DOCKER_REPO}:${TAG}}"
|
||||
if [ "${DOCKER_TARGET}" != "main" ]; then
|
||||
TARGET_DOCKER_TAG="${TARGET_DOCKER_TAG}-${DOCKER_TARGET}"
|
||||
fi
|
||||
|
@ -196,10 +213,10 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
|||
MAJOR=${BASH_REMATCH[1]}
|
||||
MINOR=${BASH_REMATCH[2]}
|
||||
|
||||
DOCKER_SHORT_TAG="${DOCKER_SHORT_TAG-${DOCKER_ORG}/${DOCKER_REPO}:v${MAJOR}.${MINOR}}"
|
||||
TARGET_DOCKER_SHORT_TAG="${DOCKER_SHORT_TAG-${DOCKER_REGISTRY}/${DOCKER_ORG}/${DOCKER_REPO}:v${MAJOR}.${MINOR}}"
|
||||
|
||||
if [ "${DOCKER_TARGET}" != "main" ]; then
|
||||
DOCKER_SHORT_TAG="${DOCKER_SHORT_TAG}-${DOCKER_TARGET}"
|
||||
TARGET_DOCKER_SHORT_TAG="${TARGET_DOCKER_SHORT_TAG}-${DOCKER_TARGET}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -216,25 +233,39 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
|||
-f "${DOCKERFILE}"
|
||||
-t "${TARGET_DOCKER_TAG}"
|
||||
)
|
||||
if [ -n "${DOCKER_SHORT_TAG}" ]; then
|
||||
DOCKER_BUILD_ARGS+=( -t "${DOCKER_SHORT_TAG}" )
|
||||
if [ -n "${TARGET_DOCKER_SHORT_TAG}" ]; then
|
||||
DOCKER_BUILD_ARGS+=( -t "${TARGET_DOCKER_SHORT_TAG}" )
|
||||
fi
|
||||
|
||||
# --label
|
||||
DOCKER_BUILD_ARGS+=(
|
||||
--label "NETBOX_DOCKER_PROJECT_VERSION=${NETBOX_DOCKER_PROJECT_VERSION}"
|
||||
--label "NETBOX_BRANCH=${BRANCH}"
|
||||
--label "ORIGINAL_DOCKER_TAG=${TARGET_DOCKER_TAG}"
|
||||
)
|
||||
if [ -d "${NETBOX_PATH}/.git" ]; then
|
||||
if [ "${DOCKER_TARGET}" == "main" ]; then
|
||||
DOCKER_BUILD_ARGS+=(
|
||||
--label "NETBOX_GIT_COMMIT=$($DRY cd "${NETBOX_PATH}"; $DRY git rev-parse HEAD)"
|
||||
--label "NETBOX_GIT_URL=$($DRY cd "${NETBOX_PATH}"; $DRY git remote get-url origin)"
|
||||
--label "ORIGINAL_TAG=${TARGET_DOCKER_TAG}"
|
||||
|
||||
--label "org.label-schema.build-date=${BUILD_DATE}"
|
||||
--label "org.opencontainers.image.created=${BUILD_DATE}"
|
||||
|
||||
--label "org.label-schema.version=${PROJECT_VERSION}"
|
||||
--label "org.opencontainers.image.version=${PROJECT_VERSION}"
|
||||
)
|
||||
if [ -d ".git" ]; then
|
||||
DOCKER_BUILD_ARGS+=(
|
||||
--label "org.label-schema.vcs-ref=${GIT_REF}"
|
||||
--label "org.opencontainers.image.revision=${GIT_REF}"
|
||||
)
|
||||
fi
|
||||
if [ -d "${NETBOX_PATH}/.git" ]; then
|
||||
DOCKER_BUILD_ARGS+=(
|
||||
--label "NETBOX_GIT_BRANCH=${NETBOX_GIT_BRANCH}"
|
||||
--label "NETBOX_GIT_REF=${NETBOX_GIT_REF}"
|
||||
--label "NETBOX_GIT_URL=${NETBOX_GIT_URL}"
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
# --build-arg
|
||||
DOCKER_BUILD_ARGS+=( --build-arg "NETBOX_PATH=${NETBOX_PATH}" )
|
||||
DOCKER_BUILD_ARGS+=( --build-arg "NETBOX_PATH=${NETBOX_PATH}" )
|
||||
|
||||
if [ -n "${DOCKER_FROM}" ]; then
|
||||
DOCKER_BUILD_ARGS+=( --build-arg "FROM=${DOCKER_FROM}" )
|
||||
fi
|
||||
|
@ -262,10 +293,10 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
|||
$DRY docker push "${TARGET_DOCKER_TAG}"
|
||||
echo "✅ Finished pushing the Docker image '${TARGET_DOCKER_TAG}'."
|
||||
|
||||
if [ -n "$DOCKER_SHORT_TAG" ]; then
|
||||
echo "⏫ Pushing '${DOCKER_SHORT_TAG}'"
|
||||
$DRY docker push "${DOCKER_SHORT_TAG}"
|
||||
echo "✅ Finished pushing the Docker image '${DOCKER_SHORT_TAG}'."
|
||||
if [ -n "${TARGET_DOCKER_SHORT_TAG}" ]; then
|
||||
echo "⏫ Pushing '${TARGET_DOCKER_SHORT_TAG}'"
|
||||
$DRY docker push "${TARGET_DOCKER_SHORT_TAG}"
|
||||
echo "✅ Finished pushing the Docker image '${TARGET_DOCKER_SHORT_TAG}'."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue