diff mbox series

[layerindex-web,RFC,1/2] Dockerfile: serve the application with uWSGI

Message ID 20261114005006.28193-2-tim.orling@konsulko.com
State New
Headers show
Series uWSGI, and a docker-compose setup with nginx-proxy | expand

Commit Message

Tim Orling Nov. 14, 2026, 12:50 a.m. UTC
Replace gunicorn with uWSGI, keeping 4 workers and the 60 second
request timeout. uWSGI serves HTTP, as gunicorn did, so the nginx
configurations work unchanged. It also serves the static files, which
are now collected into the image, for proxies that don't serve them,
such as nginx-proxy.

AI-Generated: Claude Opus 5.5
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 Dockerfile | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/Dockerfile b/Dockerfile
index f4d19ab..35c49fc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -53,7 +53,7 @@  RUN DEBIAN_FRONTEND=noninteractive apt-get update \
 	&& locale-gen en_US.UTF-8 \
 	&& update-locale \
     && pip3 install --ignore-installed setuptools wheel \
-    && pip3 install gunicorn \
+    && pip3 install uwsgi \
     && pip3 install -r /requirements.txt \
     && apt-get purge -y autoconf g++ make python3-dev pkg-config libjpeg-dev \
 	&& apt-get autoremove -y \
@@ -68,14 +68,19 @@  COPY docker/updatelayers.sh ${APP_DIR}/updatelayers.sh
 COPY docker/migrate.sh ${APP_DIR}/migrate.sh
 COPY docker/connectivity_check.sh ${APP_DIR}/connectivity_check.sh
 
-RUN mkdir ${APP_DIR}/workdir \
+RUN mkdir ${APP_DIR}/workdir ${APP_DIR}/static \
 	&& adduser --system --uid=500 --home /home/layers layers \
-	&& chown -R layers ${APP_DIR}/workdir
+	&& chown -R layers ${APP_DIR}/workdir ${APP_DIR}/static
 USER layers
 
+# Collect the static files for uWSGI to serve (see below)
+RUN cd ${APP_DIR}/layerindex \
+	&& SECRET_KEY=collectstatic STATIC_ROOT=${APP_DIR}/static python3 manage.py collectstatic --noinput -v0
+
 # Always copy in .gitconfig and proxy helper script (they need editing to be active)
 COPY docker/.gitconfig /home/layers/.gitconfig
 COPY docker/git-proxy ${APP_DIR}/bin/git-proxy
 
-# Start Gunicorn
-CMD ["/bin/sh", "-c", "/usr/local/bin/gunicorn wsgi:application --workers=4 --bind=:5000 --timeout=60 --log-level=debug --chdir=${APP_DIR}/layerindex"]
+# Start uWSGI, serving HTTP so that it works behind any proxy. It also serves
+# the static files, for proxies that don't (e.g. nginx-proxy).
+CMD ["/bin/sh", "-c", "exec /usr/local/bin/uwsgi --http-socket :5000 --master --workers 4 --enable-threads --harakiri 60 --die-on-term --need-app --chdir ${APP_DIR}/layerindex --module wsgi:application --static-map /static=${APP_DIR}/static"]