Skip to content
Snippets Groups Projects
Verified Commit 9a90faf2 authored by Quentin Duchemin's avatar Quentin Duchemin
Browse files

[MapCareTech] Add superuser, split volumes, add init-like process

parent f26b89d4
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
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`)
......
......@@ -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 $@
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment