diff --git a/caretech/map/Dockerfile b/caretech/map/Dockerfile index 89f25051a5a5956ac0191fbcfc85e1486243e990..12241659015468ea09e2fb718d89b42e2851bd09 100644 --- a/caretech/map/Dockerfile +++ b/caretech/map/Dockerfile @@ -7,8 +7,7 @@ ENV PYTHONUNBUFFERED=1 \ PORT=8000 # Create a user account and group to run uMap -RUN mkdir -p /srv/umap/{data,uploads} && \ - chown -R 10001:10001 /srv/umap && \ +RUN mkdir -p /srv/umap/static /srv/umap/uploads && \ groupadd --gid 10001 umap && \ useradd --no-create-home --uid 10001 --gid 10001 --home-dir /srv/umap umap @@ -45,11 +44,11 @@ RUN pip install umap-project==${UMAP_VERSION} # Install Docker dependencies RUN pip install -r requirements-docker.txt -COPY entrypoint.sh . COPY settings.py . +COPY entrypoint.sh . RUN chmod +x entrypoint.sh -RUN chown -R umap:umap . +RUN chown -R 10001:10001 /srv/umap USER umap diff --git a/caretech/map/docker-compose.yml b/caretech/map/docker-compose.yml index be70ecbec0d35d2433c124e810beb9e47769f69d..62d41fe0e69b4ea1ae1c769909aceb0117110ab5 100644 --- a/caretech/map/docker-compose.yml +++ b/caretech/map/docker-compose.yml @@ -1,8 +1,10 @@ version: '3.7' volumes: - app: - name: umap-caretech + app_static: + name: umap-caretech-static + app_uploads: + name: umap-caretech-uploads db: name: umap-db-caretech redis: @@ -26,7 +28,9 @@ services: # Do not allow non-authenticated users to create maps - LEAFLET_STORAGE_ALLOW_ANONYMOUS=False volumes: - - app:/srv/umap + - app_static:/srv/umap/static + - app_uploads:/srv/umap/uploads + init: true labels: traefik.http.routers.etherpad-app.entrypoints: websecure traefik.http.routers.etherpad-app.rule: Host(`carte.caretech.picasoft.net`) diff --git a/caretech/map/entrypoint.sh b/caretech/map/entrypoint.sh index fc926ab5d696a4acb3d61c8e0eb5555de482072c..3d01b850cc848031272f292e8c59791b1edbc3a5 100644 --- a/caretech/map/entrypoint.sh +++ b/caretech/map/entrypoint.sh @@ -5,27 +5,30 @@ set -eo pipefail : "${SLEEP:=1}" : "${TRIES:=60}" -function wait_for_database {( +function wait_for_database { echo "Waiting for database to respond..." tries=0 while true; do [[ $tries -lt $TRIES ]] || return - (echo "from django.db import connection; connection.connect()" | umap shell) >/dev/null 2>&1 + (echo "from django.db import connection; connection.connect()" | umap shell) [[ $? -eq 0 ]] && return sleep $SLEEP tries=$((tries + 1)) done -)} +} -# first wait for the database +echo "Wait for the database..." wait_for_database -# then migrate the database +echo "Migrate the database..." umap migrate -# then collect static files +echo "Collect static files..." umap collectstatic --noinput -# create languagae files +echo "Create language files..." umap storagei18n -# compress static files +echo "Compress static files..." umap compress -# run uWSGI -exec uwsgi --ini uwsgi.ini +echo "Create superuser..." +umap createsuperuser + +echo "Launch uMap..." +exec $@