netbox-docker/Dockerfile

118 lines
4.0 KiB
Docker
Raw Normal View History

ARG FROM
2019-10-13 16:00:42 +02:00
FROM ${FROM} as builder
2021-08-31 10:57:37 +02:00
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update -qq \
2022-06-15 09:04:00 +02:00
&& apt-get upgrade \
--yes -qq --no-install-recommends \
&& apt-get install \
--yes -qq --no-install-recommends \
2021-08-31 10:57:37 +02:00
build-essential \
ca-certificates \
2021-08-31 10:57:37 +02:00
libldap-dev \
libpq-dev \
2021-08-31 10:57:37 +02:00
libsasl2-dev \
libssl-dev \
libxml2-dev \
libxml2-dev \
libxmlsec1 \
libxmlsec1-dev \
libxmlsec1-openssl \
libxslt-dev \
pkg-config \
python3-dev \
2021-08-31 10:57:37 +02:00
python3-pip \
python3-venv \
&& python3 -m venv /opt/netbox/venv \
&& /opt/netbox/venv/bin/python3 -m pip install --upgrade \
2021-02-08 09:02:14 +01:00
pip \
setuptools \
wheel
2019-10-13 16:00:42 +02:00
ARG NETBOX_PATH
COPY ${NETBOX_PATH}/requirements.txt requirements-container.txt /
RUN sed -i -e '/psycopg2-binary/d' requirements.txt && \
/opt/netbox/venv/bin/pip install \
2021-02-08 09:02:14 +01:00
-r /requirements.txt \
-r /requirements-container.txt
2019-10-13 16:00:42 +02:00
###
# Main stage
###
ARG FROM
FROM ${FROM} as main
2021-08-31 10:57:37 +02:00
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update -qq \
&& apt-get upgrade \
--yes -qq --no-install-recommends \
&& apt-get install \
--yes -qq --no-install-recommends \
bzip2 \
2019-10-13 16:00:42 +02:00
ca-certificates \
curl \
libldap-common \
libpq5 \
libxmlsec1-openssl \
openssl \
python3 \
2021-08-31 10:57:37 +02:00
python3-distutils \
tini \
2021-08-31 10:57:37 +02:00
&& curl -sL https://nginx.org/keys/nginx_signing.key \
> /etc/apt/trusted.gpg.d/nginx.asc && \
echo "deb https://packages.nginx.org/unit/ubuntu/ jammy unit" \
2021-08-31 10:57:37 +02:00
> /etc/apt/sources.list.d/unit.list \
&& apt-get update -qq \
&& apt-get install \
--yes -qq --no-install-recommends \
unit=1.27.0-1~jammy \
unit-python3.10=1.27.0-1~jammy \
2021-08-31 10:57:37 +02:00
&& rm -rf /var/lib/apt/lists/*
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
2021-08-31 10:57:37 +02:00
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
2020-10-18 02:34:45 +02:00
COPY configuration/ /etc/netbox/config/
COPY docker/nginx-unit.json /etc/unit/
2017-08-30 11:09:24 +02:00
WORKDIR /opt/netbox/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/ \
&& chown -R unit:root media /opt/unit/ \
&& chmod -R g+w media /opt/unit/ \
2022-02-02 16:49:29 +01:00
&& cd /opt/netbox/ && SECRET_KEY="dummy" /opt/netbox/venv/bin/python -m mkdocs build \
2021-07-21 09:58:27 +02:00
--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
2019-11-17 18:03:59 +01:00
ENV LANG=C.UTF-8 PATH=/opt/netbox/venv/bin:$PATH
2021-08-31 10:57:37 +02:00
ENTRYPOINT [ "/usr/bin/tini", "--" ]
2021-09-13 08:18:23 +02:00
CMD [ "/opt/netbox/docker-entrypoint.sh", "/opt/netbox/launch-netbox.sh" ]
2021-08-31 10:57:37 +02:00
LABEL netbox.original-tag="" \
netbox.git-branch="" \
netbox.git-ref="" \
netbox.git-url="" \
# 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" \
org.opencontainers.image.description="A container based distribution of NetBox, the free and open IPAM and DCIM solution." \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.authors="The netbox-docker contributors." \
org.opencontainers.image.vendor="The netbox-docker contributors." \
org.opencontainers.image.url="https://github.com/netbox-community/netbox-docker" \
org.opencontainers.image.documentation="https://github.com/netbox-community/netbox-docker/wiki" \
org.opencontainers.image.source="https://github.com/netbox-community/netbox-docker.git" \
org.opencontainers.image.revision="" \
2022-06-15 15:47:57 +02:00
org.opencontainers.image.version=""