Skip to content

Commit 58debaf

Browse files
committed
Added container for Netbox housekeeping command
Adds an additional container in which the new "housekeeping" command from Netbox v3.0.0 is run.
1 parent 389e68f commit 58debaf

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ RUN apk add --no-cache \
6262
libevent \
6363
libffi \
6464
libjpeg-turbo \
65-
openssl \
6665
libxslt \
66+
openssl \
6767
postgresql-libs \
68-
python3 \
6968
py3-pip \
69+
python3 \
70+
tini \
7071
unit \
7172
unit-python3
7273

@@ -82,6 +83,7 @@ COPY ${NETBOX_PATH} /opt/netbox
8283

8384
COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py
8485
COPY docker/docker-entrypoint.sh /opt/netbox/docker-entrypoint.sh
86+
COPY docker/housekeeping.sh /opt/netbox/housekeeping.sh
8587
COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh
8688
COPY startup_scripts/ /opt/netbox/startup_scripts/
8789
COPY initializers/ /opt/netbox/initializers/

docker-compose.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,24 @@ services:
2020
<<: *netbox
2121
depends_on:
2222
- redis
23+
- postgres
2324
entrypoint:
25+
- "/sbin/tini"
26+
- "--"
27+
command:
2428
- /opt/netbox/venv/bin/python
2529
- /opt/netbox/netbox/manage.py
26-
command:
2730
- rqworker
31+
netbox-housekeeping:
32+
<<: *netbox
33+
depends_on:
34+
- redis
35+
- postgres
36+
entrypoint:
37+
- "/sbin/tini"
38+
- "--"
39+
command:
40+
- /opt/netbox/housekeeping.sh
2841

2942
# postgres
3043
postgres:

docker/housekeeping.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
SECONDS=${HOUSEKEEPING_INTERVAL:=86400}
3+
echo "Interval set to ${SECONDS} seconds"
4+
while true; do
5+
date
6+
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py housekeeping
7+
sleep ${SECONDS}s
8+
done

env/netbox.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ EMAIL_USERNAME=netbox
1414
# EMAIL_USE_SSL and EMAIL_USE_TLS are mutually exclusive, i.e. they can't both be `true`!
1515
EMAIL_USE_SSL=false
1616
EMAIL_USE_TLS=false
17+
HOUSEKEEPING_INTERVAL=86400
1718
MAX_PAGE_SIZE=1000
1819
MEDIA_ROOT=/opt/netbox/netbox/media
1920
METRICS_ENABLED=false

0 commit comments

Comments
 (0)