From d3a30e1172a611e52b85bc40b5ccd3d8e1f7e0f6 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Fri, 7 Oct 2022 08:08:30 +0200 Subject: [PATCH] Updated to new unit version --- Dockerfile | 6 ++-- build.sh | 2 +- docker-compose.override.yml.example | 5 ++- docker/launch-netbox.sh | 1 + docker/nginx-unit.json | 50 ++++++++++++++++++----------- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index fcf01b0..56ba2d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,8 +66,8 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && apt-get update -qq \ && apt-get install \ --yes -qq --no-install-recommends \ - unit=1.27.0-1~jammy \ - unit-python3.10=1.27.0-1~jammy \ + unit=1.29.1-1~jammy \ + unit-python3.10=1.29.1-1~jammy \ && rm -rf /var/lib/apt/lists/* COPY --from=builder /opt/netbox/venv /opt/netbox/venv @@ -94,7 +94,7 @@ RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \ --config-file /opt/netbox/mkdocs.yml --site-dir /opt/netbox/netbox/project-static/docs/ \ && SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input -ENV LANG=C.UTF-8 PATH=/opt/netbox/venv/bin:$PATH +ENV LANG=C.utf8 PATH=/opt/netbox/venv/bin:$PATH ENTRYPOINT [ "/usr/bin/tini", "--" ] CMD [ "/opt/netbox/docker-entrypoint.sh", "/opt/netbox/launch-netbox.sh" ] diff --git a/build.sh b/build.sh index cc265f9..3a72aff 100755 --- a/build.sh +++ b/build.sh @@ -332,7 +332,7 @@ elif [[ "${IMAGE_NAME_TAGS[0]}" = docker.io* ]]; then if ! printf '%s\n' "${IMAGES_LAYERS_OLD[@]}" | grep -q -P "^${BASE_LAST_LAYER}\$"; then SHOULD_BUILD="true" - BUILD_REASON="${BUILD_REASON} debian" + BUILD_REASON="${BUILD_REASON} ubuntu" fi if [ "${NETBOX_GIT_REF}" != "${NETBOX_GIT_REF_OLD}" ]; then SHOULD_BUILD="true" diff --git a/docker-compose.override.yml.example b/docker-compose.override.yml.example index 1b936f6..48365db 100644 --- a/docker-compose.override.yml.example +++ b/docker-compose.override.yml.example @@ -2,7 +2,10 @@ version: '3.4' services: netbox: ports: - - 8000:8080 + - "8000:8080" + # If you want the Nginx unit status page visible from the + # outside of the container add the following port mapping: + # - "8001:8081" healthcheck: # Time for which the health check can fail after the container is started. # This depends mostly on the performance of your database. On the first start, diff --git a/docker/launch-netbox.sh b/docker/launch-netbox.sh index 09efdb5..510c5c8 100755 --- a/docker/launch-netbox.sh +++ b/docker/launch-netbox.sh @@ -1,6 +1,7 @@ #!/bin/bash UNIT_CONFIG="${UNIT_CONFIG-/etc/unit/nginx-unit.json}" +# Also used in "nginx-unit.json" UNIT_SOCKET="/opt/unit/unit.sock" load_configuration() { diff --git a/docker/nginx-unit.json b/docker/nginx-unit.json index d6ff9cc..fc33a2c 100644 --- a/docker/nginx-unit.json +++ b/docker/nginx-unit.json @@ -1,30 +1,45 @@ { "listeners": { "0.0.0.0:8080": { - "pass": "routes" + "pass": "routes/main" }, "[::]:8080": { - "pass": "routes" + "pass": "routes/main" + }, + "0.0.0.0:8081": { + "pass": "routes/status" + }, + "[::]:8081": { + "pass": "routes/status" } }, - - "routes": [ - { - "match": { - "uri": "/static/*" + "routes": { + "main": [ + { + "match": { + "uri": "/static/*" + }, + "action": { + "share": "/opt/netbox/netbox${uri}" + } }, - "action": { - "share": "/opt/netbox/netbox${uri}" + { + "action": { + "pass": "applications/netbox" + } } - }, - - { - "action": { - "pass": "applications/netbox" + ], + "status": [ + { + "match": { + "uri": "/status/*" + }, + "action": { + "proxy": "http://unix:/opt/unit/unit.sock" + } } - } - ], - + ] + }, "applications": { "netbox": { "type": "python 3", @@ -38,6 +53,5 @@ } } }, - "access_log": "/dev/stdout" }