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

parent f26b89d4
...@@ -7,8 +7,7 @@ ENV PYTHONUNBUFFERED=1 \ ...@@ -7,8 +7,7 @@ ENV PYTHONUNBUFFERED=1 \
PORT=8000 PORT=8000
# Create a user account and group to run uMap # Create a user account and group to run uMap
RUN mkdir -p /srv/umap/{data,uploads} && \ RUN mkdir -p /srv/umap/static /srv/umap/uploads && \
chown -R 10001:10001 /srv/umap && \
groupadd --gid 10001 umap && \ groupadd --gid 10001 umap && \
useradd --no-create-home --uid 10001 --gid 10001 --home-dir /srv/umap 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} ...@@ -45,11 +44,11 @@ RUN pip install umap-project==${UMAP_VERSION}
# Install Docker dependencies # Install Docker dependencies
RUN pip install -r requirements-docker.txt RUN pip install -r requirements-docker.txt
COPY entrypoint.sh .
COPY settings.py . COPY settings.py .
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh RUN chmod +x entrypoint.sh
RUN chown -R umap:umap . RUN chown -R 10001:10001 /srv/umap
USER umap USER umap
......
version: '3.7' version: '3.7'
volumes: volumes:
app: app_static:
name: umap-caretech name: umap-caretech-static
app_uploads:
name: umap-caretech-uploads
db: db:
name: umap-db-caretech name: umap-db-caretech
redis: redis:
...@@ -26,7 +28,9 @@ services: ...@@ -26,7 +28,9 @@ services:
# Do not allow non-authenticated users to create maps # Do not allow non-authenticated users to create maps
- LEAFLET_STORAGE_ALLOW_ANONYMOUS=False - LEAFLET_STORAGE_ALLOW_ANONYMOUS=False
volumes: volumes:
- app:/srv/umap - app_static:/srv/umap/static
- app_uploads:/srv/umap/uploads
init: true
labels: labels:
traefik.http.routers.etherpad-app.entrypoints: websecure traefik.http.routers.etherpad-app.entrypoints: websecure
traefik.http.routers.etherpad-app.rule: Host(`carte.caretech.picasoft.net`) traefik.http.routers.etherpad-app.rule: Host(`carte.caretech.picasoft.net`)
......
...@@ -5,27 +5,30 @@ set -eo pipefail ...@@ -5,27 +5,30 @@ set -eo pipefail
: "${SLEEP:=1}" : "${SLEEP:=1}"
: "${TRIES:=60}" : "${TRIES:=60}"
function wait_for_database {( function wait_for_database {
echo "Waiting for database to respond..." echo "Waiting for database to respond..."
tries=0 tries=0
while true; do while true; do
[[ $tries -lt $TRIES ]] || return [[ $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 [[ $? -eq 0 ]] && return
sleep $SLEEP sleep $SLEEP
tries=$((tries + 1)) tries=$((tries + 1))
done done
)} }
# first wait for the database echo "Wait for the database..."
wait_for_database wait_for_database
# then migrate the database echo "Migrate the database..."
umap migrate umap migrate
# then collect static files echo "Collect static files..."
umap collectstatic --noinput umap collectstatic --noinput
# create languagae files echo "Create language files..."
umap storagei18n umap storagei18n
# compress static files echo "Compress static files..."
umap compress umap compress
# run uWSGI echo "Create superuser..."
exec uwsgi --ini uwsgi.ini umap createsuperuser
echo "Launch uMap..."
exec $@
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment