-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
107 lines (68 loc) · 3.06 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
ARG NETBOX_VERSION=4.2.1
ARG NETBOX_SHA_512=c66ecca5acdf330fa4ec8e4576050751d856d96faecc3d9ed87142f7b4ae0543563b4d42fe728d3b1fbdf22afbdf63244de5d4b2b71126c13f3f41774ca45510
FROM alpine:3.21.1 AS build
ARG NETBOX_VERSION
ARG NETBOX_SHA_512
ADD "https://github.com/netbox-community/netbox/archive/refs/tags/v${NETBOX_VERSION}.tar.gz" \
/tmp/netbox.tar.gz
RUN cd /tmp \
&& echo "${NETBOX_SHA_512} netbox.tar.gz" > netbox.tar.gz.sha512 \
&& sha512sum -c netbox.tar.gz.sha512 \
&& tar -xzf netbox.tar.gz -C /opt/ \
&& cp -r /opt/netbox-${NETBOX_VERSION} /opt/netbox \
&& apk add --update build-base \
cargo \
libffi-dev libjpeg-turbo-dev libpq-dev \
python3 python3-dev \
zlib-dev \
&& python3 -m venv /opt/netbox/venv \
&& /opt/netbox/venv/bin/python3 -m pip install --upgrade pip \
setuptools \
wheel \
&& /opt/netbox/venv/bin/pip install -r /opt/netbox/requirements.txt
FROM padhihomelab/alpine-base:3.21.1_0.19.0_0.2
ARG NETBOX_VERSION
COPY --from=build /opt/netbox-${NETBOX_VERSION} \
/opt/netbox/
COPY ./etc/docker-entrypoint.d/99-extra-scripts \
/etc/docker-entrypoint.d/99-extra-scripts
COPY ./usr/local/bin/netbox-healthcheck /usr/local/bin/
COPY ./usr/local/bin/netbox-housekeeping /usr/local/bin/
COPY ./usr/local/bin/netbox-rq /usr/local/bin/
COPY ./usr/local/bin/netbox-wsgi /usr/local/bin/
COPY ./usr/local/bin/start-netbox /usr/local/bin/
RUN chmod +x /etc/docker-entrypoint.d/99-extra-scripts/*.sh \
/usr/local/bin/* \
&& apk add --no-cache --update envsubst \
libffi libjpeg-turbo libpq \
nginx \
openssl \
python3 \
zlib
COPY ./etc/nginx/templates/netbox.conf.template \
/etc/nginx/templates/netbox.conf.template
COPY --from=build /opt/netbox/venv \
/opt/netbox/venv
COPY ./opt/netbox/netbox/netbox/config/configuration.py \
/opt/netbox/netbox/netbox/configuration.py
ARG SECRET_KEY="~~~~~~~~~~~~~~< SuperSecretDummyKey! >~~~~~~~~~~~~~~"
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
&& rm /etc/nginx/http.d/default.conf \
&& cd /opt/netbox \
&& cp contrib/gunicorn.py . \
&& ./venv/bin/python -m mkdocs build \
--config-file /opt/netbox/mkdocs.yml \
--site-dir /opt/netbox/netbox/project-static/docs \
&& ./venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
ENV DOCKER_USER=netbox
ENV DOCKER_GROUP=netbox
ENV NETBOX_BASE_PATH=
ENV PATH=/opt/netbox/venv/bin:$PATH
WORKDIR /opt/netbox/netbox
CMD start-netbox
EXPOSE 80
VOLUME [ "/opt/netbox/netbox/media", \
"/opt/netbox/netbox/reports", \
"/opt/netbox/netbox/scripts" ]
HEALTHCHECK --interval=15s --timeout=10s --start-period=240s \
CMD "netbox-healthcheck"