From 5f36b5bc60046f62358c2f1b062c8960816c85c3 Mon Sep 17 00:00:00 2001 From: "Andrey N. Petrov" Date: Wed, 28 Mar 2018 15:01:38 +0300 Subject: [PATCH] Leave only files needed for netbox docker image. --- Dockerfile | 4 +- README.md | 308 +--------------------------------------- build-all.sh | 60 -------- build-branches.sh | 16 --- build-latest.sh | 63 -------- build.sh | 132 ----------------- docker-compose.test.yml | 24 ---- docker-compose.yml | 46 ------ 8 files changed, 4 insertions(+), 649 deletions(-) delete mode 100755 build-all.sh delete mode 100755 build-branches.sh delete mode 100755 build-latest.sh delete mode 100755 build.sh delete mode 100644 docker-compose.test.yml delete mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index bb67af8..1b8ec32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,8 +26,8 @@ RUN pip install \ WORKDIR /opt -ARG BRANCH=master -ARG URL=https://github.com/digitalocean/netbox/archive/$BRANCH.tar.gz +ARG RELEASE=v2.3.2 +ARG URL=https://github.com/digitalocean/netbox/archive/$RELEASE.tar.gz RUN wget -q -O - "${URL}" | tar xz \ && mv netbox* netbox diff --git a/README.md b/README.md index 6741aff..ab4a1fd 100644 --- a/README.md +++ b/README.md @@ -1,306 +1,2 @@ -# 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. -Images built using this code are released to [Docker Hub][netbox-dockerhub] every night. - -[travis]: https://travis-ci.org/ninech/netbox-docker -[netbox-dockerhub]: https://hub.docker.com/r/ninech/netbox/tags/ - -## Quickstart - -To get NetBox up and running: - -``` -$ git clone -b master https://github.com/ninech/netbox-docker.git -$ cd netbox-docker -$ docker-compose pull -$ docker-compose up -d -``` - -The application will be available after a few minutes. -Use `docker-compose port nginx 8080` to find out where to connect to. - -``` -$ echo "http://$(docker-compose port nginx 8080)/" -http://0.0.0.0:32768/ - -# Open netbox in your default browser on macOS: -$ open "http://$(docker-compose port nginx 8080)/" - -# Open netbox in your default browser on (most) linuxes: -$ xdg-open "http://$(docker-compose port nginx 8080)/" &>/dev/null & -``` - -Alternatively, use something like [Reception][docker-reception] to connect to _docker-compose_ projects. - -Default credentials: - -* Username: **admin** -* Password: **admin** -* API Token: **0123456789abcdef0123456789abcdef01234567** - -[docker-reception]: https://github.com/ninech/reception - -## Dependencies - -This project relies only on *Docker* and *docker-compose* meeting this requirements: - -* The *Docker version* must be at least `1.13.0`. -* The *docker-compose version* must be at least `1.10.0`. - -To ensure this, compare the output of `docker --version` and `docker-compose --version` with the requirements above. - -## Configuration - -You can configure the app using environment variables. These are defined in `netbox.env`. -Read [Environment Variables in Compose][compose-env] to understand about the various possibilities to overwrite these variables. -(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. -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 ("` `"). -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/ - -### Production - -The default settings are optimized for (local) development environments. -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. -* `DB_*`: Use a persistent database. -* `EMAIL_*`: Use your own mailserver. -* `MAX_PAGE_SIZE`: Use the recommended default of 1000. -* `SUPERUSER_*`: Only define those variables during the initial setup, and drop them once the DB is set up. - -### Running on Docker Swarm / Kubernetes / OpenShift - -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/` 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]. -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. - -Therefore we *strongly advise* to make use of the secrets mechanism provided by your container platform (i.e. [Docker Swarm secrets][swarm-secrets], [Kubernetes secrets][k8s-secrets], [OpenShift secrets][openshift-secrets]). -[The configuration file][docker-config] and [the entrypoint script][entrypoint] try to load the following secrets from the respective files. -If a secret is defined by an environment variable and in the respective file at the same time, then the value from the environment variable is used. - -* `SUPERUSER_PASSWORD`: `/run/secrets/superuser_password` -* `SUPERUSER_API_TOKEN`: `/run/secrets/superuser_api_token` -* `DB_PASSWORD`: `/run/secrets/db_password` -* `SECRET_KEY`: `/run/secrets/secret_key` -* `EMAIL_PASSWORD`: `/run/secrets/email_password` -* `NAPALM_PASSWORD`: `/run/secrets/napalm_password` - -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 -[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 -[swarm-config]: https://docs.docker.com/engine/swarm/configs/ -[swarm-secrets]: https://docs.docker.com/engine/swarm/secrets/ -[openshift-config]: https://docs.openshift.org/latest/dev_guide/configmaps.html -[openshift-secrets]: https://docs.openshift.org/latest/dev_guide/secrets.html -[k8s-secrets]: https://kubernetes.io/docs/concepts/configuration/secret/ -[k8s-config]: https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/ - -### NAPALM Configuration - -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. -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) : - -* `NAPALM_USERNAME`: A common username that can be utilized for connecting to network devices in your environment. -* `NAPALM_PASSWORD`: The password to use in combintation with the username to connect to network devices. -* `NAPALM_TIMEOUT`: A value to use for when an attempt to connect to a device will timeout if no response has been recieved. - -However, if you don't need this functionality, leave these blank. - -[napalm-doc]: http://napalm.readthedocs.io/en/latest/index.html -[netbox-napalm-doc]: https://netbox.readthedocs.io/en/latest/configuration/optional-settings/#napalm_username - -### Custom Initialization Code (e.g. Automatically Setting Up Custom Fields) - -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: - -```python -# docker/startup_scripts/load_custom_fields.py -from django.contrib.contenttypes.models import ContentType -from extras.models import CF_TYPE_TEXT, CustomField - -from dcim.models import Device -from dcim.models import DeviceType - -device = ContentType.objects.get_for_model(Device) -device_type = ContentType.objects.get_for_model(DeviceType) - -my_custom_field, created = CustomField.objects.get_or_create( - type=CF_TYPE_TEXT, - name='my_custom_field', - description='My own custom field' -) - -if created: - my_custom_field.obj_type.add(device) - my_custom_field.obj_type.add(device_type) -``` - -#### Initializers - -Initializers are built-in startup scripts for defining NetBox custom fields, groups and users. -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. - -Here's an example for defining a custom field: - -```yaml -# initializers/custom_fields.yml -text_field: - type: text - label: Custom Text - description: Enter text in a text field. - required: false - filterable: true - weight: 0 - on_objects: - - dcim.models.Device - - dcim.models.Rack - - ipam.models.IPAddress - - ipam.models.Prefix - - tenancy.models.Tenant - - virtualization.models.VirtualMachine -``` - -[netbox-docker-initializers]: https://github.com/ninech/netbox-docker/tree/master/initializers -[netbox-docker-compose]: https://github.com/ninech/netbox-docker/blob/master/docker-compose.yml - -#### Custom Docker Image - -You can also build your own NetBox Docker image containing your own startup scripts, custom fields, users and groups -like this: - -``` -ARG VERSION=latest -FROM ninech/netbox:$VERSION - -COPY startup_scripts/ /opt/netbox/startup_scripts/ -COPY initializers/ /opt/netbox/initializers/ -``` - -## Version - -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. -`VERSION` may be set to the name of -[any tag of the `ninech/netbox` Docker image on Docker Hub][netbox-dockerhub]. - -``` -$ export VERSION=v2.2.6 -$ docker-compose pull netbox -$ docker-compose up -d -``` - -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]. -Most commonly you will specify a tag or branch name. - -``` -$ export VERSION=develop -$ docker-compose build --no-cache netbox -$ docker-compose up -d -``` - -Hint: If you're building a specific version by tag name, the `--no-cache` argument is not strictly necessary. -This can increase the build speed if you're just adjusting the config, for example. - -[git-ref]: https://git-scm.com/book/en/v2/Git-Internals-Git-References -[netbox-github]: https://github.com/digitalocean/netbox/releases - -### LDAP enabled variant - -The images tagged with "-ldap" contain anything necessary to authenticate against an LDAP or Active Directory server. -The default configuration `ldap_config.py` is prepared for use with an Active Directory server. -Custom values can be injected using environment variables, similar to the main configuration mechanisms. - -## Troubleshooting - -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. - -[issues]: (https://github.com/ninech/netbox-docker/issues) - -### Docker Compose basics - -* You can see all running containers belonging to this project using `docker-compose ps`. -* You can see the logs by running `docker-compose logs -f`. - Running `docker-compose logs -f netbox` will just show the logs for netbox. -* 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 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 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'`. - -### Getting a "Bad Request (400)" - -> 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. - -### How to upgrade - -> How do I update to a newer version? - -It should be sufficient to pull the latest image from Docker Hub, stopping the container and starting it up again: - -```bash -docker-compose pull netbox -docker-compose stop netbox -docker-compose rm -f netbox -docker-compose up -d netbox -``` - -## Rebuilding & Publishing images - -`./build.sh` is used to rebuild the Docker image: - -``` -$ ./build.sh --help -Usage: ./build.sh [--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//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 -``` - -## Tests - -To run the test coming with NetBox, use the `docker-compose.test.yml` file as such: - -``` -$ docker-compose -f docker-compose.test.yml run --rm app -``` - -## About - -This repository is currently maintained and funded by [nine](https://nine.ch), your cloud navigator. - -[![logo of the company 'nine'](https://logo.apps.at-nine.ch/Dmqied_eSaoBMQwk3vVgn4UIgDo=/trim/500x0/logo_claim.png)](https://www.nine.ch) +netbox-docker +============= diff --git a/build-all.sh b/build-all.sh deleted file mode 100755 index dcff779..0000000 --- a/build-all.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# Builds all Docker images this project provides - -VARIANTS=("" "ldap") - -if [ ! -z "${DEBUG}" ]; then - export DEBUG -fi - -ERROR=0 - -# Don't build if not on `master` and don't build if on a pull request, -# but build when DEBUG is not empty -if [ ! -z "${DEBUG}" ] || \ - ( [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] ); then - for VARIANT in "${VARIANTS[@]}"; do - export VARIANT - - # Checking which VARIANT to build - if [ -z "$VARIANT" ]; then - DOCKERFILE="Dockerfile" - else - DOCKERFILE="Dockerfile.${VARIANT}" - - # Fail fast - if [ ! -f "${DOCKERFILE}" ]; then - echo "🚨 The Dockerfile '${DOCKERFILE}' for variant '${VARIANT}' doesn't exist." - ERROR=1 - - if [ -z "$DEBUG" ]; then - continue - else - echo "⚠️ Would skip this, but DEBUG is enabled." - fi - fi - fi - - echo "🛠 Building '$DOCKERFILE'" - - # build the latest release - # shellcheck disable=SC2068 - ./build-latest.sh $@ || ERROR=1 - - # build the latest pre-release - # shellcheck disable=SC2068 - PRERELEASE=true ./build-latest.sh $@ || ERROR=1 - - # build all branches - # shellcheck disable=SC2068 - ./build-branches.sh $@ || ERROR=1 - - # special build - # shellcheck disable=SC2068 - SRC_ORG=lampwins TAG=webhooks-backend ./build.sh "feature/webhooks-backend" $@ || ERROR=1 - done -else - echo "❎ Not building anything." -fi - -exit $ERROR diff --git a/build-branches.sh b/build-branches.sh deleted file mode 100755 index e8e75d7..0000000 --- a/build-branches.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# Builds all published branches - -ORIGINAL_GITHUB_REPO="digitalocean/netbox" -GITHUB_REPO="${GITHUB_REPO-$ORIGINAL_GITHUB_REPO}" -URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/branches" - -CURL="curl -sS" - -BRANCHES=$($CURL "${URL_RELEASES}" | jq -r 'map(.name) | .[] | scan("^[^v].+")') - -for BRANCH in $BRANCHES; do - # shellcheck disable=SC2068 - ./build.sh "${BRANCH}" $@ - exit $? -done diff --git a/build-latest.sh b/build-latest.sh deleted file mode 100755 index bebe554..0000000 --- a/build-latest.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# Builds the latest released version - -ORIGINAL_GITHUB_REPO="digitalocean/netbox" -GITHUB_REPO="${GITHUB_REPO-$ORIGINAL_GITHUB_REPO}" -URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/releases" - -JQ_LATEST="group_by(.prerelease) | .[] | sort_by(.published_at) | reverse | .[0] | select(.prerelease==${PRERELEASE-false}) | .tag_name" - -CURL="curl -sS" - -VERSION=$($CURL "${URL_RELEASES}" | jq -r "${JQ_LATEST}") - -# Check if the prerelease version is actually higher than stable version -if [ "${PRERELEASE}" == "true" ]; then - JQ_STABLE="group_by(.prerelease) | .[] | sort_by(.published_at) | reverse | .[0] | select(.prerelease==false) | .tag_name" - STABLE_VERSION=$($CURL "${URL_RELEASES}" | jq -r "${JQ_STABLE}") - - # shellcheck disable=SC2003 - MAJOR_STABLE=$(expr match "${STABLE_VERSION}" 'v\([0-9]\+\)') - # shellcheck disable=SC2003 - MINOR_STABLE=$(expr match "${STABLE_VERSION}" 'v[0-9]\+\.\([0-9]\+\)') - # shellcheck disable=SC2003 - MAJOR_UNSTABLE=$(expr match "${VERSION}" 'v\([0-9]\+\)') - # shellcheck disable=SC2003 - MINOR_UNSTABLE=$(expr match "${VERSION}" 'v[0-9]\+\.\([0-9]\+\)') - - if ( [ "$MAJOR_STABLE" -eq "$MAJOR_UNSTABLE" ] && [ "$MINOR_STABLE" -ge "$MINOR_UNSTABLE" ] ) \ - || [ "$MAJOR_STABLE" -gt "$MAJOR_UNSTABLE" ]; then - echo "❎ Latest unstable version ('$VERSION') is not higher than the latest stable version ('$STABLE_VERSION')." - if [ -z "$DEBUG" ]; then - exit 0 - else - echo "⚠️ Would exit here with code '0', but DEBUG is enabled." - fi - fi -fi - -# Check if that version is not already available on docker hub: -ORIGINAL_DOCKERHUB_REPO="ninech/netbox" -DOCKERHUB_REPO="${DOCKERHUB_REPO-$ORIGINAL_DOCKERHUB_REPO}" -URL_DOCKERHUB_TOKEN="https://auth.docker.io/token?service=registry.docker.io&scope=repository:${DOCKERHUB_REPO}:pull" -BEARER_TOKEN="$($CURL "${URL_DOCKERHUB_TOKEN}" | jq -r .token)" - -URL_DOCKERHUB_TAG="https://registry.hub.docker.com/v2/${DOCKERHUB_REPO}/tags/list" -AUTHORIZATION_HEADER="Authorization: Bearer ${BEARER_TOKEN}" - -if [ -z "$VARIANT" ]; then - DOCKER_TAG="${VERSION}" -else - DOCKER_TAG="${VERSION}-${VARIANT}" -fi - -ALREADY_BUILT="$($CURL -H "${AUTHORIZATION_HEADER}" "${URL_DOCKERHUB_TAG}" | jq -e ".tags | any(.==\"${DOCKER_TAG}\")")" - -if [ "$ALREADY_BUILT" == "false" ]; then - # shellcheck disable=SC2068 - ./build.sh "${VERSION}" $@ - exit $? -else - echo "✅ ${DOCKER_TAG} already exists on https://hub.docker.com/r/${DOCKERHUB_REPO}" - exit 0 -fi diff --git a/build.sh b/build.sh deleted file mode 100755 index 7ae3ec2..0000000 --- a/build.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash -# Builds the Dockerfile[.variant] and injects tgz'ed Netbox code from Github - -set -e - -if [ "${1}x" == "x" ] || [ "${1}" == "--help" ] || [ "${1}" == "-h" ]; then - echo "Usage: ${0} [--push]" - echo " branch The branch or tag to build. Required." - echo " --push Pushes built Docker image to docker hub." - echo "" - 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 " DRY_RUN Prints all build statements instead of running them." - echo " DOCKER_OPTS Add parameters to Docker." - echo " Default:" - echo " When starts with 'v': \"\"" - echo " Else: \"--no-cache\"" - echo " BRANCH The branch to build." - echo " Also used for tagging the image." - echo " TAG The version part of the docker tag." - echo " Default:" - echo " When =master: latest" - echo " When =develop: snapshot" - echo " Else: same as " - echo " DOCKER_ORG The Docker registry (i.e. hub.docker.com/r//) " - echo " Also used for tagging the image." - echo " Default: ninech" - echo " DOCKER_REPO The Docker registry (i.e. hub.docker.com/r//) " - echo " Also used for tagging the image." - echo " Default: netbox" - 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: /:" - echo " SRC_ORG Which fork of netbox to use (i.e. github.com//)." - echo " Default: digitalocean" - echo " SRC_REPO The name of the netbox for to use (i.e. github.com//)." - echo " Default: netbox" - echo " URL Where to fetch the package from." - echo " Must be a tar.gz file of the source code." - echo " Default: https://github.com///archive/\$BRANCH.tar.gz" - echo " VARIANT The variant to build." - echo " The value will be used as a suffix to the \$TAG and for the Dockerfile" - echo " selection. The TAG being build must exist for the base variant and" - echo " corresponding Dockerfile must start with the following lines:" - echo " ARG DOCKER_ORG=ninech" - echo " ARG DOCKER_REPO=netbox" - echo " ARG FROM_TAG=latest" - echo " FROM \$DOCKER_ORG/\$DOCKER_REPO:\$FROM_TAG" - echo " Example: VARIANT=ldap will result in the tag 'latest-ldap' and the" - echo " Dockerfile 'Dockerfile.ldap' being used." - echo " Default: empty" - - if [ "${1}x" == "x" ]; then - exit 1 - else - exit 0 - fi -fi - -# variables for fetching the source -SRC_ORG="${SRC_ORG-digitalocean}" -SRC_REPO="${SRC_REPO-netbox}" -BRANCH="${1}" -URL="${URL-https://github.com/${SRC_ORG}/${SRC_REPO}/archive/$BRANCH.tar.gz}" - -# variables for tagging the docker image -DOCKER_ORG="${DOCKER_ORG-ninech}" -DOCKER_REPO="${DOCKER_REPO-netbox}" -case "${BRANCH}" in - master) - TAG="${TAG-latest}";; - develop) - TAG="${TAG-snapshot}";; - *) - TAG="${TAG-$BRANCH}";; -esac -DOCKER_TAG="${DOCKER_TAG-${DOCKER_ORG}/${DOCKER_REPO}:${TAG}}" - -# Checking which VARIANT to build -if [ -z "$VARIANT" ]; then - DOCKERFILE="Dockerfile" -else - DOCKERFILE="Dockerfile.${VARIANT}" - DOCKER_TAG="${DOCKER_TAG}-${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 exit here with code '1', but DEBUG is enabled." - fi - fi -fi - -DOCKER_OPTS=("${DOCKER_OPTS[@]}") - -# caching is only ok for version tags -case "${TAG}" in - v*) ;; - *) DOCKER_OPTS+=( "--no-cache" ) ;; -esac - -DOCKER_OPTS+=( "--pull" ) - -# Build args -DOCKER_BUILD_ARGS=( - --build-arg "FROM_TAG=${TAG}" - --build-arg "BRANCH=${BRANCH}" - --build-arg "URL=${URL}" - --build-arg "DOCKER_ORG=${DOCKER_ORG}" - --build-arg "DOCKER_REPO=${DOCKER_REPO}" -) - -if [ -z "$DRY_RUN" ]; then - DOCKER_CMD="docker" -else - echo "⚠️ DRY_RUN MODE ON ⚠️" - DOCKER_CMD="echo docker" -fi - -echo "🐳 Building the Docker image '${DOCKER_TAG}' from the url '${URL}'." -$DOCKER_CMD build -t "${DOCKER_TAG}" "${DOCKER_BUILD_ARGS[@]}" "${DOCKER_OPTS[@]}" -f "${DOCKERFILE}" . -echo "✅ Finished building the Docker images '${DOCKER_TAG}'" - -if [ "${2}" == "--push" ] ; then - echo "⏫ Pushing '${DOCKER_TAG}" - $DOCKER_CMD push "${DOCKER_TAG}" - echo "✅ Finished pushing the Docker image '${DOCKER_TAG}'." -fi diff --git a/docker-compose.test.yml b/docker-compose.test.yml deleted file mode 100644 index 158defc..0000000 --- a/docker-compose.test.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: '3' -services: - app: - build: - context: . - args: - - BRANCH=${BRANCH-master} - image: ninech/netbox:${BRANCH-latest} - depends_on: - - postgres - env_file: netbox.env - volumes: - - ./configuration:/etc/netbox:ro - command: - - ./manage.py - - test - postgres: - image: postgres:10.2-alpine - env_file: postgres.env -volumes: - netbox-static-files: - driver: local - netbox-nginx-config: - driver: local diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 71735a8..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,46 +0,0 @@ -version: '3' -services: - netbox: - build: - context: . - args: - - BRANCH=${VERSION-master} - image: ninech/netbox:${VERSION-latest} - depends_on: - - postgres - env_file: netbox.env - volumes: - - ./startup_scripts:/opt/netbox/startup_scripts:ro - - ./initializers:/opt/netbox/initializers:ro - - ./configuration:/etc/netbox:ro - - netbox-nginx-config:/etc/netbox-nginx/ - - netbox-static-files:/opt/netbox/netbox/static - - netbox-media-files:/opt/netbox/netbox/media - - netbox-report-files:/opt/netbox/netbox/reports - nginx: - image: nginx:1.13-alpine - command: nginx -g 'daemon off;' -c /etc/netbox-nginx/nginx.conf - depends_on: - - netbox - ports: - - 8080 - volumes: - - netbox-static-files:/opt/netbox/netbox/static:ro - - netbox-nginx-config:/etc/netbox-nginx/:ro - postgres: - image: postgres:10.2-alpine - env_file: postgres.env - volumes: - - netbox-postgres-data:/var/lib/postgresql/data - -volumes: - netbox-static-files: - driver: local - netbox-nginx-config: - driver: local - netbox-media-files: - driver: local - netbox-report-files: - driver: local - netbox-postgres-data: - driver: local