First version of Debian based image
This commit is contained in:
parent
df41020cb8
commit
9e2f4313fb
98
Dockerfile
98
Dockerfile
@ -1,45 +1,22 @@
|
|||||||
ARG FROM
|
ARG FROM
|
||||||
FROM ${FROM} as builder
|
FROM ${FROM} as builder
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN export DEBIAN_FRONTEND=noninteractive \
|
||||||
bash \
|
&& apt-get update -qq \
|
||||||
build-base \
|
&& apt-get install --yes -qq \
|
||||||
cargo \
|
build-essential \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
cmake \
|
libldap-dev \
|
||||||
cyrus-sasl-dev \
|
libsasl2-dev \
|
||||||
git \
|
|
||||||
graphviz \
|
|
||||||
jpeg-dev \
|
|
||||||
libevent-dev \
|
|
||||||
libffi-dev \
|
|
||||||
libxslt-dev \
|
|
||||||
make \
|
|
||||||
musl-dev \
|
|
||||||
openldap-dev \
|
|
||||||
postgresql-dev \
|
|
||||||
py3-pip \
|
|
||||||
python3-dev \
|
python3-dev \
|
||||||
|
python3-pip \
|
||||||
|
python3-venv \
|
||||||
&& python3 -m venv /opt/netbox/venv \
|
&& python3 -m venv /opt/netbox/venv \
|
||||||
&& /opt/netbox/venv/bin/python3 -m pip install --upgrade \
|
&& /opt/netbox/venv/bin/python3 -m pip install --upgrade \
|
||||||
pip \
|
pip \
|
||||||
setuptools \
|
setuptools \
|
||||||
wheel
|
wheel
|
||||||
|
|
||||||
# Build libcrc32c for google-crc32c python module
|
|
||||||
RUN git clone https://github.com/google/crc32c \
|
|
||||||
&& cd crc32c \
|
|
||||||
&& git submodule update --init --recursive \
|
|
||||||
&& mkdir build \
|
|
||||||
&& cd build \
|
|
||||||
&& cmake \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DCRC32C_BUILD_TESTS=no \
|
|
||||||
-DCRC32C_BUILD_BENCHMARKS=no \
|
|
||||||
-DBUILD_SHARED_LIBS=yes \
|
|
||||||
.. \
|
|
||||||
&& make all install
|
|
||||||
|
|
||||||
ARG NETBOX_PATH
|
ARG NETBOX_PATH
|
||||||
COPY ${NETBOX_PATH}/requirements.txt requirements-container.txt /
|
COPY ${NETBOX_PATH}/requirements.txt requirements-container.txt /
|
||||||
RUN /opt/netbox/venv/bin/pip install \
|
RUN /opt/netbox/venv/bin/pip install \
|
||||||
@ -53,35 +30,36 @@ RUN /opt/netbox/venv/bin/pip install \
|
|||||||
ARG FROM
|
ARG FROM
|
||||||
FROM ${FROM} as main
|
FROM ${FROM} as main
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN export DEBIAN_FRONTEND=noninteractive \
|
||||||
bash \
|
&& apt-get update -qq \
|
||||||
|
&& apt-get upgrade \
|
||||||
|
--yes -qq --no-install-recommends \
|
||||||
|
&& apt-get install \
|
||||||
|
--yes -qq --no-install-recommends \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
curl \
|
curl \
|
||||||
graphviz \
|
|
||||||
libevent \
|
|
||||||
libffi \
|
|
||||||
libjpeg-turbo \
|
|
||||||
libxslt \
|
|
||||||
openssl \
|
openssl \
|
||||||
postgresql-client \
|
|
||||||
postgresql-libs \
|
|
||||||
py3-pip \
|
|
||||||
python3 \
|
python3 \
|
||||||
|
python3-distutils \
|
||||||
tini \
|
tini \
|
||||||
unit \
|
&& curl -sL https://nginx.org/keys/nginx_signing.key \
|
||||||
unit-python3
|
> /etc/apt/trusted.gpg.d/nginx.asc && \
|
||||||
|
echo "deb https://packages.nginx.org/unit/debian/ bullseye unit" \
|
||||||
|
> /etc/apt/sources.list.d/unit.list \
|
||||||
|
&& apt-get update -qq \
|
||||||
|
&& apt-get install \
|
||||||
|
--yes -qq --no-install-recommends \
|
||||||
|
unit=1.27.0-1~bullseye \
|
||||||
|
unit-python3.9=1.27.0-1~bullseye \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /opt
|
|
||||||
|
|
||||||
COPY --from=builder /usr/local/lib/libcrc32c.* /usr/local/lib/
|
|
||||||
COPY --from=builder /usr/local/include/crc32c /usr/local/include
|
|
||||||
COPY --from=builder /usr/local/lib/cmake/Crc32c /usr/local/lib/cmake/
|
|
||||||
COPY --from=builder /opt/netbox/venv /opt/netbox/venv
|
COPY --from=builder /opt/netbox/venv /opt/netbox/venv
|
||||||
|
|
||||||
ARG NETBOX_PATH
|
ARG NETBOX_PATH
|
||||||
COPY ${NETBOX_PATH} /opt/netbox
|
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/ldap_config.docker.py /opt/netbox/netbox/netbox/ldap_config.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/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
|
||||||
@ -101,14 +79,15 @@ RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \
|
|||||||
--config-file /opt/netbox/mkdocs.yml --site-dir /opt/netbox/netbox/project-static/docs/ \
|
--config-file /opt/netbox/mkdocs.yml --site-dir /opt/netbox/netbox/project-static/docs/ \
|
||||||
&& SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
|
&& SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
|
||||||
|
|
||||||
ENTRYPOINT [ "/sbin/tini", "--" ]
|
ENV LANG=C.UTF-8
|
||||||
|
ENTRYPOINT [ "/usr/bin/tini", "--" ]
|
||||||
|
|
||||||
CMD [ "/opt/netbox/docker-entrypoint.sh", "/opt/netbox/launch-netbox.sh" ]
|
CMD [ "/opt/netbox/docker-entrypoint.sh", "/opt/netbox/launch-netbox.sh" ]
|
||||||
|
|
||||||
LABEL ORIGINAL_TAG="" \
|
LABEL netbox.original-tag="" \
|
||||||
NETBOX_GIT_BRANCH="" \
|
netbox.git-branch="" \
|
||||||
NETBOX_GIT_REF="" \
|
netbox.git-ref="" \
|
||||||
NETBOX_GIT_URL="" \
|
netbox.git-url="" \
|
||||||
# See http://label-schema.org/rc1/#build-time-labels
|
# See http://label-schema.org/rc1/#build-time-labels
|
||||||
# Also https://microbadger.com/labels
|
# Also https://microbadger.com/labels
|
||||||
org.label-schema.schema-version="1.0" \
|
org.label-schema.schema-version="1.0" \
|
||||||
@ -133,16 +112,3 @@ LABEL ORIGINAL_TAG="" \
|
|||||||
org.opencontainers.image.source="https://github.com/netbox-community/netbox-docker.git" \
|
org.opencontainers.image.source="https://github.com/netbox-community/netbox-docker.git" \
|
||||||
org.opencontainers.image.revision="" \
|
org.opencontainers.image.revision="" \
|
||||||
org.opencontainers.image.version="snapshot"
|
org.opencontainers.image.version="snapshot"
|
||||||
|
|
||||||
#####
|
|
||||||
## LDAP specific configuration
|
|
||||||
#####
|
|
||||||
|
|
||||||
FROM main as ldap
|
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
|
||||||
libsasl \
|
|
||||||
libldap \
|
|
||||||
util-linux
|
|
||||||
|
|
||||||
COPY docker/ldap_config.docker.py /opt/netbox/netbox/netbox/ldap_config.py
|
|
||||||
|
20
build.sh
20
build.sh
@ -49,10 +49,10 @@ if [ "${1}x" == "x" ] || [ "${1}" == "--help" ] || [ "${1}" == "-h" ]; then
|
|||||||
echo " DOCKERFILE The name of Dockerfile to use."
|
echo " DOCKERFILE The name of Dockerfile to use."
|
||||||
echo " Default: Dockerfile"
|
echo " Default: Dockerfile"
|
||||||
echo " DOCKER_FROM The base image to use."
|
echo " DOCKER_FROM The base image to use."
|
||||||
echo " Default: 'alpine:3.14'"
|
echo " Default: 'debian:bullseye-slim'"
|
||||||
echo " DOCKER_TARGET A specific target to build."
|
echo " DOCKER_TARGET A specific target to build."
|
||||||
echo " It's currently not possible to pass multiple targets."
|
echo " It's currently not possible to pass multiple targets."
|
||||||
echo " Default: main ldap"
|
echo " Default: main"
|
||||||
echo " HTTP_PROXY The proxy to use for http requests."
|
echo " HTTP_PROXY The proxy to use for http requests."
|
||||||
echo " Example: http://proxy.domain.tld:3128"
|
echo " Example: http://proxy.domain.tld:3128"
|
||||||
echo " Default: undefined"
|
echo " Default: undefined"
|
||||||
@ -170,7 +170,7 @@ fi
|
|||||||
# Determining the value for DOCKER_FROM
|
# Determining the value for DOCKER_FROM
|
||||||
###
|
###
|
||||||
if [ -z "$DOCKER_FROM" ]; then
|
if [ -z "$DOCKER_FROM" ]; then
|
||||||
DOCKER_FROM="alpine:3.14"
|
DOCKER_FROM="debian:bullseye-slim"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###
|
###
|
||||||
@ -222,7 +222,7 @@ esac
|
|||||||
###
|
###
|
||||||
# Determine targets to build
|
# Determine targets to build
|
||||||
###
|
###
|
||||||
DEFAULT_DOCKER_TARGETS=("main" "ldap")
|
DEFAULT_DOCKER_TARGETS=("main")
|
||||||
DOCKER_TARGETS=("${DOCKER_TARGET:-"${DEFAULT_DOCKER_TARGETS[@]}"}")
|
DOCKER_TARGETS=("${DOCKER_TARGET:-"${DEFAULT_DOCKER_TARGETS[@]}"}")
|
||||||
echo "🏭 Building the following targets:" "${DOCKER_TARGETS[@]}"
|
echo "🏭 Building the following targets:" "${DOCKER_TARGETS[@]}"
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
|||||||
|
|
||||||
if ! printf '%s\n' "${IMAGES_LAYERS_OLD[@]}" | grep -q -P "^${PYTHON_LAST_LAYER}\$"; then
|
if ! printf '%s\n' "${IMAGES_LAYERS_OLD[@]}" | grep -q -P "^${PYTHON_LAST_LAYER}\$"; then
|
||||||
SHOULD_BUILD="true"
|
SHOULD_BUILD="true"
|
||||||
BUILD_REASON="${BUILD_REASON} alpine"
|
BUILD_REASON="${BUILD_REASON} debian"
|
||||||
fi
|
fi
|
||||||
if [ "${NETBOX_GIT_REF}" != "${NETBOX_GIT_REF_OLD}" ]; then
|
if [ "${NETBOX_GIT_REF}" != "${NETBOX_GIT_REF_OLD}" ]; then
|
||||||
SHOULD_BUILD="true"
|
SHOULD_BUILD="true"
|
||||||
@ -335,7 +335,7 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
|||||||
|
|
||||||
# --label
|
# --label
|
||||||
DOCKER_BUILD_ARGS+=(
|
DOCKER_BUILD_ARGS+=(
|
||||||
--label "ORIGINAL_TAG=${TARGET_DOCKER_TAG_PROJECT}"
|
--label "netbox.original-tag=${TARGET_DOCKER_TAG_PROJECT}"
|
||||||
|
|
||||||
--label "org.label-schema.build-date=${BUILD_DATE}"
|
--label "org.label-schema.build-date=${BUILD_DATE}"
|
||||||
--label "org.opencontainers.image.created=${BUILD_DATE}"
|
--label "org.opencontainers.image.created=${BUILD_DATE}"
|
||||||
@ -351,14 +351,14 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
|||||||
fi
|
fi
|
||||||
if [ -d "${NETBOX_PATH}/.git" ]; then
|
if [ -d "${NETBOX_PATH}/.git" ]; then
|
||||||
DOCKER_BUILD_ARGS+=(
|
DOCKER_BUILD_ARGS+=(
|
||||||
--label "NETBOX_GIT_BRANCH=${NETBOX_GIT_BRANCH}"
|
--label "netbox.git-branch=${NETBOX_GIT_BRANCH}"
|
||||||
--label "NETBOX_GIT_REF=${NETBOX_GIT_REF}"
|
--label "netbox.git-ref=${NETBOX_GIT_REF}"
|
||||||
--label "NETBOX_GIT_URL=${NETBOX_GIT_URL}"
|
--label "netbox.git-url=${NETBOX_GIT_URL}"
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
if [ -n "${BUILD_REASON}" ]; then
|
if [ -n "${BUILD_REASON}" ]; then
|
||||||
BUILD_REASON=$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<<"$BUILD_REASON")
|
BUILD_REASON=$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<<"$BUILD_REASON")
|
||||||
DOCKER_BUILD_ARGS+=(--label "BUILD_REASON=${BUILD_REASON}")
|
DOCKER_BUILD_ARGS+=(--label "netbox.build-reason=${BUILD_REASON}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --build-arg
|
# --build-arg
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
"uri": "/static/*"
|
"uri": "/static/*"
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
"share": "/opt/netbox/netbox"
|
"share": "/opt/netbox/netbox${uri}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user