Gunicorn is replaced with nginx-unit
We now serve Netbox with an nginx-unit instance instead of Gunicorn. This allows us to get rid of the extra Nginx container because Unit is also serving the static files. The static files are now collected at container buildtime instead of every startup.
This commit is contained in:
parent
380cb77080
commit
d273391773
15 changed files with 135 additions and 136 deletions
48
Dockerfile
48
Dockerfile
|
@ -12,27 +12,15 @@ RUN apk add --no-cache \
|
|||
libffi-dev \
|
||||
libxslt-dev \
|
||||
openldap-dev \
|
||||
postgresql-dev
|
||||
|
||||
WORKDIR /install
|
||||
|
||||
RUN pip install --prefix="/install" --no-warn-script-location \
|
||||
# gunicorn is used for launching netbox
|
||||
gunicorn \
|
||||
greenlet \
|
||||
eventlet \
|
||||
# napalm is used for gathering information from network devices
|
||||
napalm \
|
||||
# ruamel is used in startup_scripts
|
||||
'ruamel.yaml>=0.15,<0.16' \
|
||||
# django_auth_ldap is required for ldap
|
||||
django_auth_ldap \
|
||||
# django-storages was introduced in 2.7 and is optional
|
||||
django-storages
|
||||
postgresql-dev \
|
||||
py3-pip \
|
||||
python3-dev \
|
||||
&& python3 -m venv /opt/netbox/venv \
|
||||
&& /opt/netbox/venv/bin/python3 -m pip install --upgrade pip setuptools
|
||||
|
||||
ARG NETBOX_PATH
|
||||
COPY ${NETBOX_PATH}/requirements.txt /
|
||||
RUN pip install --prefix="/install" --no-warn-script-location -r /requirements.txt
|
||||
COPY ${NETBOX_PATH}/requirements.txt requirements-container.txt /
|
||||
RUN /opt/netbox/venv/bin/pip install -r /requirements.txt -r /requirements-container.txt
|
||||
|
||||
###
|
||||
# Main stage
|
||||
|
@ -44,6 +32,7 @@ FROM ${FROM} as main
|
|||
RUN apk add --no-cache \
|
||||
bash \
|
||||
ca-certificates \
|
||||
curl \
|
||||
graphviz \
|
||||
libevent \
|
||||
libffi \
|
||||
|
@ -51,35 +40,38 @@ RUN apk add --no-cache \
|
|||
libressl \
|
||||
libxslt \
|
||||
postgresql-libs \
|
||||
ttf-ubuntu-font-family
|
||||
python3 \
|
||||
py3-pip \
|
||||
ttf-ubuntu-font-family \
|
||||
unit \
|
||||
unit-python3
|
||||
|
||||
WORKDIR /opt
|
||||
|
||||
COPY --from=builder /install /usr/local
|
||||
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/gunicorn_config.py /etc/netbox/
|
||||
COPY docker/nginx.conf /etc/netbox-nginx/nginx.conf
|
||||
COPY docker/docker-entrypoint.sh /opt/netbox/docker-entrypoint.sh
|
||||
COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh
|
||||
COPY startup_scripts/ /opt/netbox/startup_scripts/
|
||||
COPY initializers/ /opt/netbox/initializers/
|
||||
COPY configuration/ /etc/netbox/config/
|
||||
COPY docker/nginx-unit.json /etc/unit/
|
||||
|
||||
WORKDIR /opt/netbox/netbox
|
||||
|
||||
# Must set permissions for '/opt/netbox/netbox/static' directory
|
||||
# to g+w so that `./manage.py collectstatic` can be executed during
|
||||
# container startup.
|
||||
# Must set permissions for '/opt/netbox/netbox/media' directory
|
||||
# to g+w so that pictures can be uploaded to netbox.
|
||||
RUN mkdir static && chmod -R g+w static media
|
||||
RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \
|
||||
&& chmod -R g+w media /opt/unit/ \
|
||||
&& SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
|
||||
|
||||
ENTRYPOINT [ "/opt/netbox/docker-entrypoint.sh" ]
|
||||
|
||||
CMD ["gunicorn", "-c /etc/netbox/gunicorn_config.py", "netbox.wsgi"]
|
||||
CMD [ "/opt/netbox/launch-netbox.sh" ]
|
||||
|
||||
LABEL ORIGINAL_TAG="" \
|
||||
NETBOX_GIT_BRANCH="" \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue