From 3e0a6b8f1008c3aad7cff78eecd720e1c915bb49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Fri, 14 Mar 2025 15:20:56 +0100 Subject: [PATCH] Update the Dockerfile to expose websockets The Dockerfile now uses ASGI by default (via uvicorn) and embeds a redis server that is used for the synchronization. --- Dockerfile | 10 +++++----- docker/entrypoint.sh | 5 +++-- pyproject.toml | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index bc58c96c..bfac62fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ # This part installs deps needed at runtime. -FROM python:3.11-slim AS common +FROM python:3.11-slim AS runtime RUN apt-get update && \ apt-get install -y --no-install-recommends \ tini \ - uwsgi \ sqlite3 \ libpq-dev \ + redis-server \ gdal-bin \ && \ apt-get autoremove -y && \ @@ -14,7 +14,7 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # This part adds deps needed only at buildtime. -FROM common AS build +FROM runtime AS build RUN apt-get update && \ apt-get install -y --no-install-recommends \ @@ -39,9 +39,9 @@ WORKDIR /srv/umap COPY . /srv/umap -RUN /venv/bin/pip install .[docker,s3] +RUN /venv/bin/pip install .[docker,s3,sync] -FROM common +FROM runtime COPY --from=build /srv/umap/docker/ /srv/umap/docker/ COPY --from=build /venv/ /venv/ diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 8ed7fdfb..515fa472 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -2,6 +2,7 @@ set -eo pipefail source /venv/bin/activate +service redis-server start # collect static files umap collectstatic --noinput @@ -9,5 +10,5 @@ umap collectstatic --noinput umap wait_for_database # then migrate the database umap migrate -# run uWSGI -exec uwsgi --ini docker/uwsgi.ini +# run the server +exec uvicorn --proxy-headers --no-access-log umap.asgi:application diff --git a/pyproject.toml b/pyproject.toml index 800c12ab..45960b1a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ test = [ "moto[s3]==5.1.1" ] docker = [ - "uwsgi==2.0.28", + "uvicorn==0.34.0", ] s3 = [ "django-storages[s3]==1.14.5", @@ -73,6 +73,7 @@ s3 = [ sync = [ "pydantic==2.10.6", "redis==5.2.1", + "websockets==15.0.1", ] [project.scripts]