Skip to content

Commit 9e2f431

Browse files
committed
First version of Debian based image
1 parent df41020 commit 9e2f431

File tree

3 files changed

+45
-79
lines changed

3 files changed

+45
-79
lines changed

Dockerfile

Lines changed: 34 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,22 @@
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 install --yes -qq \
7+
build-essential \
88
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 \
9+
libldap-dev \
10+
libsasl2-dev \
2211
python3-dev \
23-
&& python3 -m venv /opt/netbox/venv \
24-
&& /opt/netbox/venv/bin/python3 -m pip install --upgrade \
12+
python3-pip \
13+
python3-venv \
14+
&& python3 -m venv /opt/netbox/venv \
15+
&& /opt/netbox/venv/bin/python3 -m pip install --upgrade \
2516
pip \
2617
setuptools \
2718
wheel
2819

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-
4320
ARG NETBOX_PATH
4421
COPY ${NETBOX_PATH}/requirements.txt requirements-container.txt /
4522
RUN /opt/netbox/venv/bin/pip install \
@@ -53,35 +30,36 @@ RUN /opt/netbox/venv/bin/pip install \
5330
ARG FROM
5431
FROM ${FROM} as main
5532

56-
RUN apk add --no-cache \
57-
bash \
33+
RUN export DEBIAN_FRONTEND=noninteractive \
34+
&& apt-get update -qq \
35+
&& apt-get upgrade \
36+
--yes -qq --no-install-recommends \
37+
&& apt-get install \
38+
--yes -qq --no-install-recommends \
5839
ca-certificates \
5940
curl \
60-
graphviz \
61-
libevent \
62-
libffi \
63-
libjpeg-turbo \
64-
libxslt \
6541
openssl \
66-
postgresql-client \
67-
postgresql-libs \
68-
py3-pip \
6942
python3 \
43+
python3-distutils \
7044
tini \
71-
unit \
72-
unit-python3
73-
74-
WORKDIR /opt
45+
&& curl -sL https://nginx.org/keys/nginx_signing.key \
46+
> /etc/apt/trusted.gpg.d/nginx.asc && \
47+
echo "deb https://packages.nginx.org/unit/debian/ bullseye unit" \
48+
> /etc/apt/sources.list.d/unit.list \
49+
&& apt-get update -qq \
50+
&& apt-get install \
51+
--yes -qq --no-install-recommends \
52+
unit=1.27.0-1~bullseye \
53+
unit-python3.9=1.27.0-1~bullseye \
54+
&& rm -rf /var/lib/apt/lists/*
7555

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/
7956
COPY --from=builder /opt/netbox/venv /opt/netbox/venv
8057

8158
ARG NETBOX_PATH
8259
COPY ${NETBOX_PATH} /opt/netbox
8360

8461
COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py
62+
COPY docker/ldap_config.docker.py /opt/netbox/netbox/netbox/ldap_config.py
8563
COPY docker/docker-entrypoint.sh /opt/netbox/docker-entrypoint.sh
8664
COPY docker/housekeeping.sh /opt/netbox/housekeeping.sh
8765
COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh
@@ -101,14 +79,15 @@ RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \
10179
--config-file /opt/netbox/mkdocs.yml --site-dir /opt/netbox/netbox/project-static/docs/ \
10280
&& SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
10381

104-
ENTRYPOINT [ "/sbin/tini", "--" ]
82+
ENV LANG=C.UTF-8
83+
ENTRYPOINT [ "/usr/bin/tini", "--" ]
10584

10685
CMD [ "/opt/netbox/docker-entrypoint.sh", "/opt/netbox/launch-netbox.sh" ]
10786

108-
LABEL ORIGINAL_TAG="" \
109-
NETBOX_GIT_BRANCH="" \
110-
NETBOX_GIT_REF="" \
111-
NETBOX_GIT_URL="" \
87+
LABEL netbox.original-tag="" \
88+
netbox.git-branch="" \
89+
netbox.git-ref="" \
90+
netbox.git-url="" \
11291
# See http://label-schema.org/rc1/#build-time-labels
11392
# Also https://microbadger.com/labels
11493
org.label-schema.schema-version="1.0" \
@@ -133,16 +112,3 @@ LABEL ORIGINAL_TAG="" \
133112
org.opencontainers.image.source="https://github.com/netbox-community/netbox-docker.git" \
134113
org.opencontainers.image.revision="" \
135114
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:bullseye-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:bullseye-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

0 commit comments

Comments
 (0)