Skip to content

Commit bce5259

Browse files
authored
Merge pull request #775 from tobiasge/debian-based
Debian based
2 parents 1130ff6 + c3c94b0 commit bce5259

File tree

5 files changed

+54
-81
lines changed

5 files changed

+54
-81
lines changed

.hadolint.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
ignored:
22
- DL3006
3-
- DL3018
3+
- DL3008
4+
- DL3003

Dockerfile

Lines changed: 40 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,27 @@
11
ARG FROM
22
FROM ${FROM} as builder
33

4-
RUN apk add --no-cache \
5-
bash \
6-
build-base \
7-
cargo \
4+
RUN export DEBIAN_FRONTEND=noninteractive \
5+
&& apt-get update -qq \
6+
&& apt-get upgrade \
7+
--yes -qq --no-install-recommends \
8+
&& apt-get install \
9+
--yes -qq --no-install-recommends \
10+
build-essential \
811
ca-certificates \
9-
cmake \
10-
cyrus-sasl-dev \
11-
git \
12-
graphviz \
13-
jpeg-dev \
14-
libevent-dev \
15-
libffi-dev \
16-
libxslt-dev \
17-
make \
18-
musl-dev \
19-
openldap-dev \
20-
postgresql-dev \
21-
py3-pip \
12+
libldap-dev \
13+
libpq-dev \
14+
libsasl2-dev \
15+
libssl-dev \
2216
python3-dev \
23-
&& python3 -m venv /opt/netbox/venv \
24-
&& /opt/netbox/venv/bin/python3 -m pip install --upgrade \
17+
python3-pip \
18+
python3-venv \
19+
&& python3 -m venv /opt/netbox/venv \
20+
&& /opt/netbox/venv/bin/python3 -m pip install --upgrade \
2521
pip \
2622
setuptools \
2723
wheel
2824

29-
# Build libcrc32c for google-crc32c python module
30-
RUN git clone https://github.com/google/crc32c \
31-
&& cd crc32c \
32-
&& git submodule update --init --recursive \
33-
&& mkdir build \
34-
&& cd build \
35-
&& cmake \
36-
-DCMAKE_BUILD_TYPE=Release \
37-
-DCRC32C_BUILD_TESTS=no \
38-
-DCRC32C_BUILD_BENCHMARKS=no \
39-
-DBUILD_SHARED_LIBS=yes \
40-
.. \
41-
&& make all install
42-
4325
ARG NETBOX_PATH
4426
COPY ${NETBOX_PATH}/requirements.txt requirements-container.txt /
4527
RUN /opt/netbox/venv/bin/pip install \
@@ -53,35 +35,37 @@ RUN /opt/netbox/venv/bin/pip install \
5335
ARG FROM
5436
FROM ${FROM} as main
5537

56-
RUN apk add --no-cache \
57-
bash \
38+
RUN export DEBIAN_FRONTEND=noninteractive \
39+
&& apt-get update -qq \
40+
&& apt-get upgrade \
41+
--yes -qq --no-install-recommends \
42+
&& apt-get install \
43+
--yes -qq --no-install-recommends \
5844
ca-certificates \
5945
curl \
60-
graphviz \
61-
libevent \
62-
libffi \
63-
libjpeg-turbo \
64-
libxslt \
46+
libpq5 \
6547
openssl \
66-
postgresql-client \
67-
postgresql-libs \
68-
py3-pip \
6948
python3 \
49+
python3-distutils \
7050
tini \
71-
unit \
72-
unit-python3
73-
74-
WORKDIR /opt
51+
&& curl -sL https://nginx.org/keys/nginx_signing.key \
52+
> /etc/apt/trusted.gpg.d/nginx.asc && \
53+
echo "deb https://packages.nginx.org/unit/debian/ bullseye unit" \
54+
> /etc/apt/sources.list.d/unit.list \
55+
&& apt-get update -qq \
56+
&& apt-get install \
57+
--yes -qq --no-install-recommends \
58+
unit=1.27.0-1~bullseye \
59+
unit-python3.9=1.27.0-1~bullseye \
60+
&& rm -rf /var/lib/apt/lists/*
7561

76-
COPY --from=builder /usr/local/lib/libcrc32c.* /usr/local/lib/
77-
COPY --from=builder /usr/local/include/crc32c /usr/local/include
78-
COPY --from=builder /usr/local/lib/cmake/Crc32c /usr/local/lib/cmake/
7962
COPY --from=builder /opt/netbox/venv /opt/netbox/venv
8063

8164
ARG NETBOX_PATH
8265
COPY ${NETBOX_PATH} /opt/netbox
8366

8467
COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py
68+
COPY docker/ldap_config.docker.py /opt/netbox/netbox/netbox/ldap_config.py
8569
COPY docker/docker-entrypoint.sh /opt/netbox/docker-entrypoint.sh
8670
COPY docker/housekeeping.sh /opt/netbox/housekeeping.sh
8771
COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh
@@ -101,14 +85,15 @@ RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \
10185
--config-file /opt/netbox/mkdocs.yml --site-dir /opt/netbox/netbox/project-static/docs/ \
10286
&& SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
10387

104-
ENTRYPOINT [ "/sbin/tini", "--" ]
88+
ENV LANG=C.UTF-8
89+
ENTRYPOINT [ "/usr/bin/tini", "--" ]
10590

10691
CMD [ "/opt/netbox/docker-entrypoint.sh", "/opt/netbox/launch-netbox.sh" ]
10792

108-
LABEL ORIGINAL_TAG="" \
109-
NETBOX_GIT_BRANCH="" \
110-
NETBOX_GIT_REF="" \
111-
NETBOX_GIT_URL="" \
93+
LABEL netbox.original-tag="" \
94+
netbox.git-branch="" \
95+
netbox.git-ref="" \
96+
netbox.git-url="" \
11297
# See http://label-schema.org/rc1/#build-time-labels
11398
# Also https://microbadger.com/labels
11499
org.label-schema.schema-version="1.0" \
@@ -133,16 +118,3 @@ LABEL ORIGINAL_TAG="" \
133118
org.opencontainers.image.source="https://github.com/netbox-community/netbox-docker.git" \
134119
org.opencontainers.image.revision="" \
135120
org.opencontainers.image.version="snapshot"
136-
137-
#####
138-
## LDAP specific configuration
139-
#####
140-
141-
FROM main as ldap
142-
143-
RUN apk add --no-cache \
144-
libsasl \
145-
libldap \
146-
util-linux
147-
148-
COPY docker/ldap_config.docker.py /opt/netbox/netbox/netbox/ldap_config.py

build.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ if [ "${1}x" == "x" ] || [ "${1}" == "--help" ] || [ "${1}" == "-h" ]; then
4949
echo " DOCKERFILE The name of Dockerfile to use."
5050
echo " Default: Dockerfile"
5151
echo " DOCKER_FROM The base image to use."
52-
echo " Default: 'alpine:3.14'"
52+
echo " Default: 'debian:11-slim'"
5353
echo " DOCKER_TARGET A specific target to build."
5454
echo " It's currently not possible to pass multiple targets."
55-
echo " Default: main ldap"
55+
echo " Default: main"
5656
echo " HTTP_PROXY The proxy to use for http requests."
5757
echo " Example: http://proxy.domain.tld:3128"
5858
echo " Default: undefined"
@@ -170,7 +170,7 @@ fi
170170
# Determining the value for DOCKER_FROM
171171
###
172172
if [ -z "$DOCKER_FROM" ]; then
173-
DOCKER_FROM="alpine:3.14"
173+
DOCKER_FROM="debian:11-slim"
174174
fi
175175

176176
###
@@ -222,7 +222,7 @@ esac
222222
###
223223
# Determine targets to build
224224
###
225-
DEFAULT_DOCKER_TARGETS=("main" "ldap")
225+
DEFAULT_DOCKER_TARGETS=("main")
226226
DOCKER_TARGETS=("${DOCKER_TARGET:-"${DEFAULT_DOCKER_TARGETS[@]}"}")
227227
echo "🏭 Building the following targets:" "${DOCKER_TARGETS[@]}"
228228

@@ -302,7 +302,7 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
302302

303303
if ! printf '%s\n' "${IMAGES_LAYERS_OLD[@]}" | grep -q -P "^${PYTHON_LAST_LAYER}\$"; then
304304
SHOULD_BUILD="true"
305-
BUILD_REASON="${BUILD_REASON} alpine"
305+
BUILD_REASON="${BUILD_REASON} debian"
306306
fi
307307
if [ "${NETBOX_GIT_REF}" != "${NETBOX_GIT_REF_OLD}" ]; then
308308
SHOULD_BUILD="true"
@@ -335,7 +335,7 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
335335

336336
# --label
337337
DOCKER_BUILD_ARGS+=(
338-
--label "ORIGINAL_TAG=${TARGET_DOCKER_TAG_PROJECT}"
338+
--label "netbox.original-tag=${TARGET_DOCKER_TAG_PROJECT}"
339339

340340
--label "org.label-schema.build-date=${BUILD_DATE}"
341341
--label "org.opencontainers.image.created=${BUILD_DATE}"
@@ -351,14 +351,14 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
351351
fi
352352
if [ -d "${NETBOX_PATH}/.git" ]; then
353353
DOCKER_BUILD_ARGS+=(
354-
--label "NETBOX_GIT_BRANCH=${NETBOX_GIT_BRANCH}"
355-
--label "NETBOX_GIT_REF=${NETBOX_GIT_REF}"
356-
--label "NETBOX_GIT_URL=${NETBOX_GIT_URL}"
354+
--label "netbox.git-branch=${NETBOX_GIT_BRANCH}"
355+
--label "netbox.git-ref=${NETBOX_GIT_REF}"
356+
--label "netbox.git-url=${NETBOX_GIT_URL}"
357357
)
358358
fi
359359
if [ -n "${BUILD_REASON}" ]; then
360360
BUILD_REASON=$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<<"$BUILD_REASON")
361-
DOCKER_BUILD_ARGS+=(--label "BUILD_REASON=${BUILD_REASON}")
361+
DOCKER_BUILD_ARGS+=(--label "netbox.build-reason=${BUILD_REASON}")
362362
fi
363363

364364
# --build-arg

docker/nginx-unit.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"uri": "/static/*"
1212
},
1313
"action": {
14-
"share": "/opt/netbox/netbox"
14+
"share": "/opt/netbox/netbox${uri}"
1515
}
1616
},
1717

requirements-container.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
django-auth-ldap==4.1.0
22
django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.12.3
3-
google-crc32c==1.3.0
43
napalm==3.4.1
4+
psycopg2==2.9.3
55
ruamel.yaml==0.17.21

0 commit comments

Comments
 (0)