Build multi-arch images based on Debian
This commit is contained in:
parent
b0261e8cc6
commit
7ec68ecccb
6 changed files with 465 additions and 350 deletions
108
Dockerfile
108
Dockerfile
|
@ -1,44 +1,31 @@
|
|||
ARG FROM
|
||||
FROM ${FROM} as builder
|
||||
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
build-base \
|
||||
cargo \
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update -qq \
|
||||
&& apt-get install \
|
||||
--yes -qq --no-install-recommends \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
cmake \
|
||||
cyrus-sasl-dev \
|
||||
git \
|
||||
graphviz \
|
||||
jpeg-dev \
|
||||
libevent-dev \
|
||||
libffi-dev \
|
||||
libxslt-dev \
|
||||
make \
|
||||
musl-dev \
|
||||
openldap-dev \
|
||||
postgresql-dev \
|
||||
py3-pip \
|
||||
libjpeg-dev \
|
||||
libldap-dev \
|
||||
libsasl2-dev \
|
||||
libxslt1-dev \
|
||||
libxml2-dev \
|
||||
postgresql-13 \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
&& python3 -m venv /opt/netbox/venv \
|
||||
&& /opt/netbox/venv/bin/python3 -m pip install --upgrade \
|
||||
pip \
|
||||
setuptools \
|
||||
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
|
||||
WORKDIR /opt/netbox/
|
||||
|
||||
ARG NETBOX_PATH
|
||||
COPY ${NETBOX_PATH}/requirements.txt requirements-container.txt /
|
||||
|
@ -53,34 +40,39 @@ RUN /opt/netbox/venv/bin/pip install \
|
|||
ARG FROM
|
||||
FROM ${FROM} as main
|
||||
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN . /etc/os-release \
|
||||
&& apt-get update -qq \
|
||||
&& apt-get upgrade \
|
||||
--yes -qq --no-install-recommends \
|
||||
&& apt-get install \
|
||||
--yes -qq --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
graphviz \
|
||||
libevent \
|
||||
libffi \
|
||||
libjpeg-turbo \
|
||||
libxslt \
|
||||
openssl \
|
||||
postgresql-libs \
|
||||
py3-pip \
|
||||
python3 \
|
||||
tini \
|
||||
python3-distutils \
|
||||
&& curl -sL https://nginx.org/keys/nginx_signing.key | \
|
||||
tee /etc/apt/trusted.gpg.d/nginx.asc \
|
||||
&& echo "deb https://packages.nginx.org/unit/debian/ ${VERSION_CODENAME} unit" | \
|
||||
tee /etc/apt/sources.list.d/unit.list \
|
||||
&& apt-get update -qq \
|
||||
&& apt-get install \
|
||||
--yes -qq --no-install-recommends \
|
||||
unit \
|
||||
unit-python3
|
||||
unit-python3.9 \
|
||||
tini \
|
||||
&& 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
|
||||
|
||||
ARG NETBOX_PATH
|
||||
COPY ${NETBOX_PATH} /opt/netbox
|
||||
|
||||
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/housekeeping.sh /opt/netbox/housekeeping.sh
|
||||
COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh
|
||||
|
@ -89,17 +81,18 @@ COPY initializers/ /opt/netbox/initializers/
|
|||
COPY configuration/ /etc/netbox/config/
|
||||
COPY docker/nginx-unit.json /etc/unit/
|
||||
|
||||
WORKDIR /opt/netbox/netbox
|
||||
WORKDIR /opt/netbox
|
||||
|
||||
# Must set permissions for '/opt/netbox/netbox/media' directory
|
||||
# to g+w so that pictures can be uploaded to netbox.
|
||||
RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \
|
||||
&& chmod -R g+w media /opt/unit/ \
|
||||
&& cd /opt/netbox/ && /opt/netbox/venv/bin/python -m mkdocs build \
|
||||
&& chmod -R g+w /opt/netbox/netbox/media /opt/unit/ \
|
||||
&& /opt/netbox/venv/bin/python -m mkdocs build \
|
||||
--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
|
||||
|
||||
ENTRYPOINT [ "/sbin/tini", "--" ]
|
||||
WORKDIR /opt/netbox/netbox
|
||||
ENTRYPOINT [ "/usr/bin/tini", "--" ]
|
||||
|
||||
CMD [ "/opt/netbox/docker-entrypoint.sh", "/opt/netbox/launch-netbox.sh" ]
|
||||
|
||||
|
@ -107,18 +100,6 @@ LABEL ORIGINAL_TAG="" \
|
|||
NETBOX_GIT_BRANCH="" \
|
||||
NETBOX_GIT_REF="" \
|
||||
NETBOX_GIT_URL="" \
|
||||
# See http://label-schema.org/rc1/#build-time-labels
|
||||
# Also https://microbadger.com/labels
|
||||
org.label-schema.schema-version="1.0" \
|
||||
org.label-schema.build-date="" \
|
||||
org.label-schema.name="NetBox Docker" \
|
||||
org.label-schema.description="A container based distribution of NetBox, the free and open IPAM and DCIM solution." \
|
||||
org.label-schema.vendor="The netbox-docker contributors." \
|
||||
org.label-schema.url="https://github.com/netbox-community/netbox-docker" \
|
||||
org.label-schema.usage="https://github.com/netbox-community/netbox-docker/wiki" \
|
||||
org.label-schema.vcs-url="https://github.com/netbox-community/netbox-docker.git" \
|
||||
org.label-schema.vcs-ref="" \
|
||||
org.label-schema.version="snapshot" \
|
||||
# See https://github.com/opencontainers/image-spec/blob/master/annotations.md#pre-defined-annotation-keys
|
||||
org.opencontainers.image.created="" \
|
||||
org.opencontainers.image.title="NetBox Docker" \
|
||||
|
@ -131,16 +112,3 @@ LABEL ORIGINAL_TAG="" \
|
|||
org.opencontainers.image.source="https://github.com/netbox-community/netbox-docker.git" \
|
||||
org.opencontainers.image.revision="" \
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue