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/docs/config/settings.md b/docs/config/settings.md index 5211f7b5..deea1148 100644 --- a/docs/config/settings.md +++ b/docs/config/settings.md @@ -354,52 +354,7 @@ Otherwise, use any valid [python-social-auth configuration](https://python-socia #### WEBSOCKET_ENABLED -A WebSocket server is packaged with uMap, and can be turned-on to activate -"real-time collaboration". In practice, in order to enable it, a few settings -are exposed. +Setting `WEBSOCKET_ENABLED` to `True` will allow users to enable real-time collaboration. +A switch will be available for them in the "advanced properties" of the map. -Setting `WEBSOCKET_ENABLED` to `True` will **not** enable real-time -collaboration on all the maps served by the server. Instead, a switch will be -available in the "advanced properties" of the map. - -The websocket server can be started with the following command: - -```bash -umap run_websocket_server -``` - -And can take optional settings `--host` and `--port` (default values are defined in -the settings). - -Configuration example: - -```python -WEBSOCKET_ENABLED = True -WEBSOCKET_BACK_HOST = "localhost" -WEBSOCKET_BACK_PORT = 8002 -WEBSOCKET_FRONT_URI = "ws://localhost:8002" -``` - -These settings can also be set with the (same names) environment variables. - -#### WEBSOCKET_BACK_HOST -#### WEBSOCKET_BACK_PORT - -The internal host and port the websocket server will connect to. - -#### WEBSOCKET_FRONT_URI - -The connection string that will be used by the client to connect to the -websocket server. In practice, as it's useful to put the WebSocket server behind -TLS encryption, the values defined by `WEBSOCKET_FRONT_URI` are different than -the values defined by `WEBSOCKET_BACK_PORT` and `WEBSOCKET_BACK_HOST`. - -This value is comprised of three parts: - -``` -protocol://host:port -``` - -- `protocol`: can either be `ws` for plain unencrypted WebSockets, or `wss` when using TLS encryption. -- `host`: is the address where the connection will be sent. It should be public facing. -- `port`: is the port that is open on the host. +See [the documentation about ASGI deployment](../deploy/asgi.md) for more information. diff --git a/docs/deploy/docker.md b/docs/deploy/docker.md index 7d99e80c..3f08e421 100644 --- a/docs/deploy/docker.md +++ b/docs/deploy/docker.md @@ -48,3 +48,19 @@ User accounts can be managed via the Django admin page ({SITE_URL}/admin). The r ```bash umap createsuperuser ``` + +## Developping with Docker + +If you want to develop with podman or docker, here are commands that might be useful, given that you have a postgreSQL server running locally and that your settings are located at `umap.conf`: + +You can build the docker image with: + +```bash +podman build -t umap . +``` + +And run it with: + +```bash +podman run -v ./umap.conf:/tmp/umap.conf -e UMAP_SETTINGS=/tmp/umap.conf -it --network host umap +``` diff --git a/pyproject.toml b/pyproject.toml index e2143a4c..44c4a8e0 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]