mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-02-01 11:52:20 +00:00
docker: move initial setup into docker startup to simplify deployment
This commit is contained in:
parent
61d8748d59
commit
db74b4f909
2 changed files with 37 additions and 0 deletions
|
@ -10,3 +10,7 @@ RUN apt-get update && apt-get install -y gettext libgettextpo-dev tidy && apt-ge
|
|||
|
||||
COPY requirements.txt /app/
|
||||
RUN pip install -r requirements.txt --no-cache-dir
|
||||
ADD . /app
|
||||
|
||||
|
||||
ENTRYPOINT [ "/app/bookwyrm/setup.sh" ]
|
||||
|
|
33
bookwyrm/setup.sh
Executable file
33
bookwyrm/setup.sh
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
# Perform initial setup so that the users don't have to
|
||||
# This should only be done in the web container;
|
||||
# the celery and flower containers should wait for the canary to exist
|
||||
|
||||
CANARY=/app/static/.dbinit_done
|
||||
|
||||
info() { echo >&2 "$*" ; }
|
||||
die() { echo >&2 "$*" ; exit 1 ; }
|
||||
|
||||
if [ "$1" == "exit" ]; then
|
||||
info "**** base container exiting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$DB_INIT" ]; then
|
||||
while [ ! -r "$CANARY" ]; do
|
||||
info "**** Waiting for database and migrations to finish"
|
||||
sleep 10
|
||||
done
|
||||
elif [ ! -r "$CANARY" ]; then
|
||||
info "**** Doing initial setup!"
|
||||
python manage.py migrate || die "failed to migrate"
|
||||
python manage.py migrate django_celery_beat || die "failed to migrate django"
|
||||
python manage.py initdb || die "failed to initdb"
|
||||
python manage.py collectstatic --no-input || die "failed to collect static"
|
||||
python manage.py admin_code
|
||||
|
||||
info "**** Done with initial setup!"
|
||||
touch "$CANARY"
|
||||
fi
|
||||
|
||||
exec bash -c "$*"
|
Loading…
Reference in a new issue