-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
configure entrypoint to create_db on startup of flask service via doc…
…ker-compose
- Loading branch information
1 parent
a9288e6
commit 1ef4368
Showing
3 changed files
with
32 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
# Flask | ||
FLASK_APP=project/__init__.py | ||
FLASK_ENV=development | ||
# db is a specific reference to the service in the docker-compose.yml file | ||
DATABASE_URL=postgresql://<user>:<password>@db:5432/<db> | ||
|
||
# Postgres | ||
POSTGRES_USER=<user> | ||
POSTGRES_PASSWORD=<password> | ||
POSTGRES_DB=<db> | ||
SQL_HOST=<db> | ||
SQL_HOST=db | ||
SQL_PORT=5432 | ||
DATABASE=postgres | ||
DATABASE=postgres | ||
|
||
# SQLAlchemy | ||
# db is a specific reference to the service in the docker-compose.yml file | ||
DATABASE_URL=postgresql://<POSTGRES_USER>:<POSTGRES_PASSWORD>@<SQL_HOST>:5432/<POSTGRES_DB> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
# Verify Postgres is up and healthy | ||
# Note: File permissions requirement | ||
# - chmod +x services/web/entrypoint.sh | ||
if [ "$DATABASE" = "postgres" ] | ||
then | ||
echo "Waiting for postgres..." | ||
|
||
while ! nc -z $SQL_HOST $SQL_PORT; do | ||
sleep 0.1 | ||
done | ||
|
||
echo "PostgreSQL started" | ||
fi | ||
|
||
python manage.py create_db | ||
|
||
exec "$@" |