Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Add Django database migrations to Dockerfile entrypoint #1049

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ DJANGO_DATABASE_HOST=db
UPSTREAM_DATABASE_HOST=upstream_db
UPSTREAM_DATABASE_PORT=5432

DJANGO_MIGRATE_DB_ON_STARTUP=False

SEMANTIC_VERSION=1.0.0

ELASTICSEARCH_URL=es
Expand Down
6 changes: 6 additions & 0 deletions api/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ while [ "$(curl -s -o /dev/null -w '%{http_code}' "$es_url")" != "200" ]; do
done
echo "Elasticsearch connection established!"

# Run any database migrations
if [ "$DJANGO_MIGRATE_DB_ON_STARTUP" != "False" ]; then
echo "Running database migrations..."
python manage.py migrate
fi

exec "$@"