From d3dd6a2f6997eebafd085a1375091060b8b55a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ma=CC=88der?= Date: Wed, 29 Nov 2017 10:55:43 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=90=9E=20Adds=20most=20common=20hostn?= =?UTF-8?q?ames=20to=20ALLOWED=5FHOSTS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `nginx.netboxdocker.docker` and `netboxdocker.docker` are required if our ['reception'][1] thing is used to access the container. Fixes #21 [1]: https://github.com/ninech/reception --- netbox.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox.env b/netbox.env index 4bc812f..3e0c7e1 100644 --- a/netbox.env +++ b/netbox.env @@ -1,7 +1,7 @@ SUPERUSER_NAME=admin SUPERUSER_EMAIL=admin@example.com SUPERUSER_PASSWORD=admin -ALLOWED_HOSTS=localhost +ALLOWED_HOSTS=localhost 0.0.0.0 127.0.0.1 [::1] netboxdocker.docker nginx.netboxdocker.docker DB_NAME=netbox DB_USER=netbox DB_PASSWORD=J5brHrAXFLQSif0K From 7b69fd8a1cf405596969b1ab9a8468827b1b4953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ma=CC=88der?= Date: Wed, 29 Nov 2017 15:08:55 +0100 Subject: [PATCH 2/4] =?UTF-8?q?=E2=9C=A8=20Creates=20a=20token=20for=20adm?= =?UTF-8?q?in=20by=20default?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/docker-entrypoint.sh | 30 ++++++++++++++++++++---------- netbox.env | 3 ++- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index f830bd5..f58b9bf 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -1,30 +1,40 @@ #!/bin/bash set -e -# run db migrations (retry on error) +# wait shortly and then run db migrations (retry on error) while ! ./manage.py migrate 2>&1; do - sleep 5 + echo "⏳ Waiting on DB..." + sleep 3 done # create superuser silently -if [[ -z ${SUPERUSER_NAME} || -z ${SUPERUSER_EMAIL} || -z ${SUPERUSER_PASSWORD} ]]; then - SUPERUSER_NAME='admin' - SUPERUSER_EMAIL='admin@example.com' - SUPERUSER_PASSWORD='admin' - echo "Using defaults: Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}, Password: ${SUPERUSER_PASSWORD}" +if [[ -z ${SUPERUSER_NAME} ]]; then + SUPERUSER_NAME='admin' fi +if [[ -z ${SUPERUSER_EMAIL} ]]; then + SUPERUSER_EMAIL='admin@example.com' +fi +if [[ -z ${SUPERUSER_PASSWORD} ]]; then + SUPERUSER_PASSWORD='admin' +fi +if [[ -z ${SUPERUSER_API_TOKEN} ]]; then + SUPERUSER_API_TOKEN='0123456789abcdef0123456789abcdef01234567' +fi + +echo "💡 Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}, Password: ${SUPERUSER_PASSWORD}, Token: ${SUPERUSER_API_TOKEN}" ./manage.py shell --plain << END from django.contrib.auth.models import User +from users.models import Token if not User.objects.filter(username='${SUPERUSER_NAME}'): - User.objects.create_superuser('${SUPERUSER_NAME}', '${SUPERUSER_EMAIL}', '${SUPERUSER_PASSWORD}') + u=User.objects.create_superuser('${SUPERUSER_NAME}', '${SUPERUSER_EMAIL}', '${SUPERUSER_PASSWORD}') + Token.objects.create(user=u, key='${SUPERUSER_API_TOKEN}') END # copy static files ./manage.py collectstatic --no-input -echo "✅ Initialisation is done. Launching CMD:" -echo "exec ${@}" +echo "✅ Initialisation is done." # launch whatever is passed by docker via RUN exec ${@} diff --git a/netbox.env b/netbox.env index 3e0c7e1..9bed821 100644 --- a/netbox.env +++ b/netbox.env @@ -1,7 +1,8 @@ SUPERUSER_NAME=admin SUPERUSER_EMAIL=admin@example.com SUPERUSER_PASSWORD=admin -ALLOWED_HOSTS=localhost 0.0.0.0 127.0.0.1 [::1] netboxdocker.docker nginx.netboxdocker.docker +SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567 +ALLOWED_HOSTS=localhost 0.0.0.0 127.0.0.1 [::1] netbox nginx netboxdocker.docker nginx.netboxdocker.docker DB_NAME=netbox DB_USER=netbox DB_PASSWORD=J5brHrAXFLQSif0K From e4ddfc925ca439beaed64385cf7bc28bff6a16b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ma=CC=88der?= Date: Wed, 29 Nov 2017 15:13:55 +0100 Subject: [PATCH 3/4] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Some=20README=20improv?= =?UTF-8?q?ements=20in=20the=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8cbef06..c141d6d 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ 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 ``` @@ -29,10 +30,14 @@ $ open "http://$(docker-compose port nginx 80)/" $ xdg-open "http://$(docker-compose port nginx 80)/" &>/dev/null & ``` +Alternatively, use something like [Reception](https://github.com/ninech/reception) to +connect to _docker-compose_ projects. + Default credentials: * Username: **admin** * Password: **admin** +* API Token: **0123456789abcdef0123456789abcdef01234567** ## Dependencies @@ -55,7 +60,7 @@ To use this feature, set the environment-variable `VERSION` before launching `do [any tag of the `ninech/netbox` Docker image](https://hub.docker.com/r/ninech/netbox/tags/). ``` -$ export VERSION=v2.2.1 +$ export VERSION=v2.2.6 $ docker-compose pull netbox $ docker-compose up -d ``` From 2aa582f3ce85cf1860b62a8908ea46a6c8e01d5f Mon Sep 17 00:00:00 2001 From: nathbooth Date: Fri, 1 Dec 2017 09:27:30 +0000 Subject: [PATCH 4/4] Added ttf-ubuntu-font-family The present build does not include a font-family causing Graphviz to render text as blank squares, including the ttf ubuntu font-family means text is rendered correctly --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 8e3a1cd..df564cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ RUN apk add --no-cache \ ca-certificates \ cyrus-sasl-dev \ graphviz \ + ttf-ubuntu-font-family \ jpeg-dev \ libffi-dev \ libxml2-dev \