automatically run migrations on docker container start by default
This commit is contained in:
parent
ddfa684c97
commit
ebac0e5f77
2 changed files with 13 additions and 0 deletions
|
@ -67,6 +67,7 @@ COPY --chown=root:root --chmod=0755 /docker/entrypoint.sh /usr/bin/entrypoint
|
|||
ENV C3NAV_DEBUG="" \
|
||||
C3NAV_LOGLEVEL="info" \
|
||||
C3NAV_DATA_DIR="/data" \
|
||||
C3NAV_AUTOMIGRATE="yes" \
|
||||
MPLBACKEND="agg" \
|
||||
UWSGI_WORKERS="8"
|
||||
|
||||
|
|
|
@ -5,8 +5,17 @@ cd /app
|
|||
# enable python virtual env
|
||||
. /app/env/bin/activate
|
||||
|
||||
automigrate() {
|
||||
AUTOMIGRATE="${C3NAV_AUTOMIGRATE:no}"
|
||||
echo "Running migrations as automigrate is enabled. Set \"C3NAV_AUTOMIGRATE\" to \"no\" or \"false\" to disable."
|
||||
if [[ "$AUTOMIGRATE" == "yes" || "$AUTOMIGRATE" == "true" ]]; then
|
||||
python manage.py migrate
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
web)
|
||||
automigrate
|
||||
exec /app/env/bin/uwsgi --master \
|
||||
--wsgi "c3nav.wsgi" \
|
||||
--pythonpath "/app/src" \
|
||||
|
@ -15,6 +24,7 @@ web)
|
|||
--http "0.0.0.0:8000"
|
||||
;;
|
||||
webstatic)
|
||||
automigrate
|
||||
exec /app/env/bin/uwsgi --master \
|
||||
--wsgi "c3nav.wsgi" \
|
||||
--pythonpath "/app/src" \
|
||||
|
@ -25,9 +35,11 @@ webstatic)
|
|||
--http "0.0.0.0:8000"
|
||||
;;
|
||||
web-async)
|
||||
automigrate
|
||||
exec python -m uvicorn --host 0.0.0.0 --proxy-headers --no-server-header ${*:2} c3nav.asgi:application
|
||||
;;
|
||||
webstatic-async)
|
||||
automigrate
|
||||
exec python -m uvicorn --host 0.0.0.0 --proxy-headers --no-server-header ${*:2} c3nav.asgi:static_app
|
||||
;;
|
||||
worker)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue