From 1ea16d9ab56114f0528b8a1d328ad2e91c4e44c9 Mon Sep 17 00:00:00 2001 From: Quentin Duchemin <quentinduchemin@tuta.io> Date: Wed, 23 Sep 2020 20:26:49 +0200 Subject: [PATCH] [MapCareTech] Add uWGSI to avoid development server and configure port in Compose --- caretech/map/Dockerfile | 12 ++++++------ caretech/map/docker-compose.yml | 10 ++++------ caretech/map/settings.py | 27 +++++++++++++++++++++++++++ caretech/map/uwsgi.ini | 10 ++++++++++ 4 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 caretech/map/uwsgi.ini diff --git a/caretech/map/Dockerfile b/caretech/map/Dockerfile index 9a8849ad..5bfedf0c 100644 --- a/caretech/map/Dockerfile +++ b/caretech/map/Dockerfile @@ -3,8 +3,7 @@ FROM python:3.8-buster ARG UMAP_VERSION=1.2.1 ENV PYTHONUNBUFFERED=1 \ - UMAP_SETTINGS=/srv/umap/settings.py \ - PORT=8000 + UMAP_SETTINGS=/srv/umap/settings.py # Create a user account and group to run uMap RUN mkdir -p /srv/umap/static /srv/umap/uploads && \ @@ -44,14 +43,15 @@ RUN pip install umap-project==${UMAP_VERSION} # Install Docker dependencies RUN pip install -r requirements-docker.txt -COPY entrypoint.sh / +COPY entrypoint.sh . +COPY uwsgi.init . -RUN chmod +x /entrypoint.sh +RUN chmod +x ./entrypoint.sh RUN chown -R 10001:10001 /srv/umap USER umap EXPOSE 8000 -ENTRYPOINT [ "/entrypoint.sh" ] -CMD [ "umap", "runserver", "0.0.0.0:8000" ] +ENTRYPOINT [ "/srv/umap/entrypoint.sh" ] +CMD [ "uwsgi", "--ini", "uwsgi.ini" ] diff --git a/caretech/map/docker-compose.yml b/caretech/map/docker-compose.yml index 29298258..56c8187c 100644 --- a/caretech/map/docker-compose.yml +++ b/caretech/map/docker-compose.yml @@ -1,8 +1,6 @@ version: '3.7' volumes: - app_static: - name: umap-caretech-static app_uploads: name: umap-caretech-uploads db: @@ -23,12 +21,12 @@ services: container_name: umap-caretech env_file: ./secrets/umap.secrets environment: - - REDIS_URL=redis://redis:6379/0 - - SITE_URL=https://carte.caretech.picasoft.net + REDIS_URL: redis://redis:6379/0 + SITE_URL: https://carte.caretech.picasoft.net # Do not allow non-authenticated users to create maps - - LEAFLET_STORAGE_ALLOW_ANONYMOUS=False + LEAFLET_STORAGE_ALLOW_ANONYMOUS: False + PORT: 8000 volumes: - - app_static:/srv/umap/static - app_uploads:/srv/umap/uploads - ./settings.py:/srv/umap/settings.py init: true diff --git a/caretech/map/settings.py b/caretech/map/settings.py index 668e8078..2b3f0369 100644 --- a/caretech/map/settings.py +++ b/caretech/map/settings.py @@ -97,3 +97,30 @@ LEAFLET_STORAGE_KEEP_VERSIONS = env.int( 'LEAFLET_STORAGE_KEEP_VERSIONS', default=10, ) + +import sys + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'verbose': { + 'format': '[django] %(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' + } + }, + 'handlers': { + 'console': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + 'stream': sys.stdout, + 'formatter': 'verbose' + }, + }, + 'loggers': { + 'django': { + 'handlers': ['console'], + 'level': 'DEBUG', + 'propagate': True, + }, + }, +} diff --git a/caretech/map/uwsgi.ini b/caretech/map/uwsgi.ini new file mode 100644 index 00000000..2cf2c279 --- /dev/null +++ b/caretech/map/uwsgi.ini @@ -0,0 +1,10 @@ +[uwsgi] +http = :$(PORT) +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 -- GitLab