Added container for Netbox housekeeping command

Adds an additional container in which the new "housekeeping" command from
Netbox v3.0.0 is run.
This commit is contained in:
Tobias Genannt 2021-09-03 12:48:30 +02:00
parent 389e68f6ba
commit 58debafa8a
4 changed files with 27 additions and 3 deletions

View File

@ -62,11 +62,12 @@ RUN apk add --no-cache \
libevent \ libevent \
libffi \ libffi \
libjpeg-turbo \ libjpeg-turbo \
openssl \
libxslt \ libxslt \
openssl \
postgresql-libs \ postgresql-libs \
python3 \
py3-pip \ py3-pip \
python3 \
tini \
unit \ unit \
unit-python3 unit-python3
@ -82,6 +83,7 @@ COPY ${NETBOX_PATH} /opt/netbox
COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py
COPY docker/docker-entrypoint.sh /opt/netbox/docker-entrypoint.sh COPY docker/docker-entrypoint.sh /opt/netbox/docker-entrypoint.sh
COPY docker/housekeeping.sh /opt/netbox/housekeeping.sh
COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh
COPY startup_scripts/ /opt/netbox/startup_scripts/ COPY startup_scripts/ /opt/netbox/startup_scripts/
COPY initializers/ /opt/netbox/initializers/ COPY initializers/ /opt/netbox/initializers/

View File

@ -20,11 +20,24 @@ services:
<<: *netbox <<: *netbox
depends_on: depends_on:
- redis - redis
- postgres
entrypoint: entrypoint:
- "/sbin/tini"
- "--"
command:
- /opt/netbox/venv/bin/python - /opt/netbox/venv/bin/python
- /opt/netbox/netbox/manage.py - /opt/netbox/netbox/manage.py
command:
- rqworker - rqworker
netbox-housekeeping:
<<: *netbox
depends_on:
- redis
- postgres
entrypoint:
- "/sbin/tini"
- "--"
command:
- /opt/netbox/housekeeping.sh
# postgres # postgres
postgres: postgres:

8
docker/housekeeping.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
SECONDS=${HOUSEKEEPING_INTERVAL:=86400}
echo "Interval set to ${SECONDS} seconds"
while true; do
date
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py housekeeping
sleep ${SECONDS}s
done

1
env/netbox.env vendored
View File

@ -14,6 +14,7 @@ EMAIL_USERNAME=netbox
# EMAIL_USE_SSL and EMAIL_USE_TLS are mutually exclusive, i.e. they can't both be `true`! # EMAIL_USE_SSL and EMAIL_USE_TLS are mutually exclusive, i.e. they can't both be `true`!
EMAIL_USE_SSL=false EMAIL_USE_SSL=false
EMAIL_USE_TLS=false EMAIL_USE_TLS=false
HOUSEKEEPING_INTERVAL=86400
MAX_PAGE_SIZE=1000 MAX_PAGE_SIZE=1000
MEDIA_ROOT=/opt/netbox/netbox/media MEDIA_ROOT=/opt/netbox/netbox/media
METRICS_ENABLED=false METRICS_ENABLED=false