Skip to content

Commit 6a52a48

Browse files
authored
Merge pull request #582 from netbox-community/develop
Version 1.4.0
2 parents e021390 + e31492a commit 6a52a48

11 files changed

+52
-14
lines changed

Dockerfile

Lines changed: 6 additions & 4 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/
@@ -98,9 +100,9 @@ RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \
98100
--config-file /opt/netbox/mkdocs.yml --site-dir /opt/netbox/netbox/project-static/docs/ \
99101
&& SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
100102

101-
ENTRYPOINT [ "/opt/netbox/docker-entrypoint.sh" ]
103+
ENTRYPOINT [ "/sbin/tini", "--" ]
102104

103-
CMD [ "/opt/netbox/launch-netbox.sh" ]
105+
CMD [ "/opt/netbox/docker-entrypoint.sh", "/opt/netbox/launch-netbox.sh" ]
104106

105107
LABEL ORIGINAL_TAG="" \
106108
NETBOX_GIT_BRANCH="" \

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.1
1+
1.4.0

build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ NETBOX_PATH="${NETBOX_PATH-.netbox}"
118118
# Fetching the NetBox source
119119
###
120120
if [ "${2}" != "--push-only" ] && [ -z "${SKIP_GIT}" ]; then
121+
REMOTE_EXISTS=$(git ls-remote --heads --tags "${URL}" "${NETBOX_BRANCH}" | wc -l)
122+
if [ "${REMOTE_EXISTS}" == "0" ]; then
123+
echo "❌ Remote branch '${NETBOX_BRANCH}' not found in '${URL}'; Nothing to do"
124+
if [ -n "${GH_ACTION}" ]; then
125+
echo "::set-output name=skipped::true"
126+
fi
127+
exit 0
128+
fi
121129
echo "🌐 Checking out '${NETBOX_BRANCH}' of NetBox from the url '${URL}' into '${NETBOX_PATH}'"
122130
if [ ! -d "${NETBOX_PATH}" ]; then
123131
$DRY git clone -q --depth 10 -b "${NETBOX_BRANCH}" "${URL}" "${NETBOX_PATH}"

docker-compose.test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ services:
1717
- ./reports:/etc/netbox/reports:z,ro
1818
- ./scripts:/etc/netbox/scripts:z,ro
1919
- netbox-media-files:/opt/netbox/netbox/media:z
20-
ports:
21-
- 8080
2220
postgres:
2321
image: postgres:13-alpine
2422
env_file: env/postgres.env

docker-compose.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@ services:
2020
<<: *netbox
2121
depends_on:
2222
- redis
23-
entrypoint:
23+
- postgres
24+
command:
2425
- /opt/netbox/venv/bin/python
2526
- /opt/netbox/netbox/manage.py
26-
command:
2727
- rqworker
28+
netbox-housekeeping:
29+
<<: *netbox
30+
depends_on:
31+
- redis
32+
- postgres
33+
command:
34+
- /opt/netbox/housekeeping.sh
2835

2936
# postgres
3037
postgres:

docker/docker-entrypoint.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@ source /opt/netbox/venv/bin/activate
1515
DB_WAIT_TIMEOUT=${DB_WAIT_TIMEOUT-3}
1616
MAX_DB_WAIT_TIME=${MAX_DB_WAIT_TIME-30}
1717
CUR_DB_WAIT_TIME=0
18-
while ! ./manage.py showmigrations >/dev/null 2>&1 && [ "${CUR_DB_WAIT_TIME}" -lt "${MAX_DB_WAIT_TIME}" ]; do
18+
while [ "${CUR_DB_WAIT_TIME}" -lt "${MAX_DB_WAIT_TIME}" ]; do
19+
# Read and truncate connection error tracebacks to last line by default
20+
exec {psfd}< <(./manage.py showmigrations 2>&1)
21+
read -rd '' DB_ERR <&$psfd || :
22+
exec {psfd}<&-
23+
wait $! && break
24+
if [ -n "$DB_WAIT_DEBUG" ]; then
25+
echo "$DB_ERR"
26+
else
27+
readarray -tn 0 DB_ERR_LINES <<<"$DB_ERR"
28+
echo "${DB_ERR_LINES[@]: -1}"
29+
echo "[ Use DB_WAIT_DEBUG=1 in netbox.env to print full traceback for errors here ]"
30+
fi
1931
echo "⏳ Waiting on DB... (${CUR_DB_WAIT_TIME}s / ${MAX_DB_WAIT_TIME}s)"
2032
sleep "${DB_WAIT_TIMEOUT}"
2133
CUR_DB_WAIT_TIME=$((CUR_DB_WAIT_TIME + DB_WAIT_TIMEOUT))

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

docker/launch-netbox.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ exec unitd \
5151
--pid /opt/unit/unit.pid \
5252
--log /dev/stdout \
5353
--state /opt/unit/state/ \
54-
--tmp /opt/unit/tmp/
54+
--tmp /opt/unit/tmp/ \
55+
--user 101 \
56+
--group 0

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

requirements-container.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
napalm==3.3.1
22
ruamel.yaml==0.17.16
33
django-auth-ldap==3.0.0
4-
google-crc32c==1.1.4
4+
google-crc32c==1.1.5
55
django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.11.1

0 commit comments

Comments
 (0)