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.
This commit is contained in:
Alexis Métaireau 2025-03-14 15:20:56 +01:00
parent d85fc648b1
commit 3e0a6b8f10
No known key found for this signature in database
GPG key ID: 1C21B876828E5FF2
3 changed files with 10 additions and 8 deletions

View file

@ -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/

View file

@ -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

View file

@ -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]