1
1
ARG FROM
2
2
FROM ${FROM} AS builder
3
3
4
+ COPY --from=ghcr.io/astral-sh/uv:0.5 /uv /usr/local/bin/
4
5
RUN export DEBIAN_FRONTEND=noninteractive \
5
6
&& apt-get update -qq \
6
7
&& apt-get upgrade \
@@ -20,24 +21,19 @@ RUN export DEBIAN_FRONTEND=noninteractive \
20
21
libxslt-dev \
21
22
pkg-config \
22
23
python3-dev \
23
- python3-pip \
24
- python3-venv \
25
- && python3 -m venv /opt/netbox/venv \
26
- && /opt/netbox/venv/bin/python3 -m pip install --upgrade \
27
- pip \
28
- setuptools \
29
- wheel
24
+ && /usr/local/bin/uv venv /opt/netbox/venv
30
25
31
26
ARG NETBOX_PATH
32
27
COPY ${NETBOX_PATH}/requirements.txt requirements-container.txt /
28
+ ENV VIRTUAL_ENV=/opt/netbox/venv
33
29
RUN \
34
30
# Gunicorn is not needed because we use Nginx Unit
35
31
sed -i -e '/gunicorn/d' /requirements.txt && \
36
32
# We need 'social-auth-core[all]' in the Docker image. But if we put it in our own requirements-container.txt
37
33
# we have potential version conflicts and the build will fail.
38
34
# That's why we just replace it in the original requirements.txt.
39
35
sed -i -e 's/social-auth-core/social-auth-core\[ all\] /g' /requirements.txt && \
40
- /opt/netbox/venv/ bin/pip install \
36
+ /usr/local/ bin/uv pip install \
41
37
-r /requirements.txt \
42
38
-r /requirements-container.txt
43
39
@@ -75,12 +71,13 @@ RUN export DEBIAN_FRONTEND=noninteractive \
75
71
unit-python3.12=1.34.1-1~noble \
76
72
&& rm -rf /var/lib/apt/lists/*
77
73
74
+ # Copy the modified 'requirements*.txt' files, to have the files actually used during installation
75
+ COPY --from=builder /requirements.txt /requirements-container.txt /opt/netbox/
76
+ COPY --from=builder /usr/local/bin/uv /usr/local/bin/
78
77
COPY --from=builder /opt/netbox/venv /opt/netbox/venv
79
78
80
79
ARG NETBOX_PATH
81
80
COPY ${NETBOX_PATH} /opt/netbox
82
- # Copy the modified 'requirements*.txt' files, to have the files actually used during installation
83
- COPY --from=builder /requirements.txt /requirements-container.txt /opt/netbox/
84
81
85
82
COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py
86
83
COPY docker/ldap_config.docker.py /opt/netbox/netbox/netbox/ldap_config.py
@@ -89,6 +86,7 @@ COPY docker/housekeeping.sh /opt/netbox/housekeeping.sh
89
86
COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh
90
87
COPY configuration/ /etc/netbox/config/
91
88
COPY docker/nginx-unit.json /etc/unit/
89
+ COPY VERSION /opt/netbox/VERSION
92
90
93
91
WORKDIR /opt/netbox/netbox
94
92
@@ -99,9 +97,11 @@ RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \
99
97
&& chmod -R g+w /opt/unit/ media reports scripts \
100
98
&& cd /opt/netbox/ && SECRET_KEY="dummyKeyWithMinimumLength-------------------------" /opt/netbox/venv/bin/python -m mkdocs build \
101
99
--config-file /opt/netbox/mkdocs.yml --site-dir /opt/netbox/netbox/project-static/docs/ \
102
- && SECRET_KEY="dummyKeyWithMinimumLength-------------------------" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
100
+ && DEBUG="true" SECRET_KEY="dummyKeyWithMinimumLength-------------------------" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input \
101
+ && mkdir /opt/netbox/netbox/local \
102
+ && echo "build: Docker-$(cat /opt/netbox/VERSION)" > /opt/netbox/netbox/local/release.yaml
103
103
104
- ENV LANG=C.utf8 PATH=/opt/netbox/venv/bin:$PATH
104
+ ENV LANG=C.utf8 PATH=/opt/netbox/venv/bin:$PATH VIRTUAL_ENV=/opt/netbox/venv UV_NO_CACHE=1
105
105
ENTRYPOINT [ "/usr/bin/tini" , "--" ]
106
106
107
107
CMD [ "/opt/netbox/docker-entrypoint.sh" , "/opt/netbox/launch-netbox.sh" ]
0 commit comments