diff --git a/Dockerfile b/Dockerfile index bfac62fe..d4df0f5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,6 @@ RUN apt-get update && \ tini \ sqlite3 \ libpq-dev \ - redis-server \ gdal-bin \ && \ apt-get autoremove -y && \ diff --git a/docker-compose.yml b/docker-compose.yml index eae9d801..e3b44f77 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,15 @@ services: + # Usefull only to use the real time collaboration + redis: + image: redis:latest + healthcheck: + test: ["CMD-SHELL", "redis-cli ping | grep PONG"] + interval: 1s + timeout: 3s + retries: 5 + command: ["redis-server"] + db: healthcheck: test: [ "CMD-SHELL", "pg_isready -U postgres" ] @@ -14,7 +24,9 @@ services: depends_on: db: condition: service_healthy - image: umap/umap:2.0.2 + redis: + condition: service_healthy + image: umap/umap:2.9.3 ports: - "${PORT-8000}:8000" environment: @@ -23,6 +35,8 @@ services: - SITE_URL=https://umap.local/ - UMAP_ALLOW_ANONYMOUS=True - DEBUG=1 + - WEBSOCKET_ENABLED=1 + - REDIS_URL=redis://redis:6379 volumes: - data:/srv/umap/uploads diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 515fa472..c2510db9 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -2,7 +2,6 @@ set -eo pipefail source /venv/bin/activate -service redis-server start # collect static files umap collectstatic --noinput @@ -11,4 +10,4 @@ umap wait_for_database # then migrate the database umap migrate # run the server -exec uvicorn --proxy-headers --no-access-log umap.asgi:application +exec uvicorn --proxy-headers --no-access-log --host 0.0.0.0 umap.asgi:application diff --git a/docker/uwsgi.ini b/docker/uwsgi.ini deleted file mode 100644 index 02a648c6..00000000 --- a/docker/uwsgi.ini +++ /dev/null @@ -1,26 +0,0 @@ -[uwsgi] -http = :$(PORT) -home = /venv -module = umap.wsgi:application -master = True -vacuum = True -max-requests = 5000 -processes = 4 -enable-threads = true -static-map = /static=/srv/umap/static -static-map = /uploads=/srv/umap/uploads -buffer-size = 32768 - -; Run the websocket server only when the env variable -; WEBSOCKET_ENABLED is set to True. -; This is enough for the base docker image, but does not -; take into account the settings as the source of truth. -if-env = WEBSOCKET_ENABLED -websocket_enabled = %(_) -endif = - -if-opt = websocket_enabled=True -print = Starting the Websocket Server (WEBSOCKET_ENABLED=%(websocket_enabled)) -attach-daemon = umap run_websocket_server -endif = -lazy-apps = true \ No newline at end of file diff --git a/docs/deploy/docker.md b/docs/deploy/docker.md index 3f08e421..84ced49e 100644 --- a/docs/deploy/docker.md +++ b/docs/deploy/docker.md @@ -14,7 +14,7 @@ services: app: # Check https://hub.docker.com/r/umap/umap/tags to find the latest version - image: umap/umap:2.0.2 + image: umap/umap:2.9.3 ports: # modify the external port (8001, on the left) if desired, but make sure it matches SITE_URL, below - "8001:8000" @@ -64,3 +64,29 @@ And run it with: ```bash podman run -v ./umap.conf:/tmp/umap.conf -e UMAP_SETTINGS=/tmp/umap.conf -it --network host umap ``` + +## Real time collaboration + +To enable real time collaboration when using Docker, a Redis service must be added. Something like this in `docker-compose.py` world: + +```yaml title="docker-compose.yml" +services + redis: + image: redis:latest + healthcheck: + test: ["CMD-SHELL", "redis-cli ping | grep PONG"] +… + command: ["redis-server"] +… + app: + depends_on: +… + redis: + condition: service_healthy +… + environment: + - WEBSOCKET_ENABLED=1 + - REDIS_URL=redis://redis:6379 +… + +``` diff --git a/umap/settings/base.py b/umap/settings/base.py index ecb51326..1e0cdd69 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -346,4 +346,4 @@ WEBSOCKET_ENABLED = env.bool("WEBSOCKET_ENABLED", default=False) WEBSOCKET_BACK_HOST = env("WEBSOCKET_BACK_HOST", default="localhost") WEBSOCKET_BACK_PORT = env.int("WEBSOCKET_BACK_PORT", default=8001) -REDIS_URL = "redis://localhost:6379" +REDIS_URL = env("REDIS_URL", default="redis://localhost:6379")