-
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.
Add db.env --> store shared database environment variables Add wait-for-postgres.sh --> let crm container run django server after database being ready to connect
- Loading branch information
KingCSharp
committed
Mar 28, 2019
1 parent
30b08e2
commit 34d0b9b
Showing
5 changed files
with
35 additions
and
11 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
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,6 @@ | ||
# Database environment variables | ||
POSTGRES_USER=postgres | ||
POSTGRES_PASSWORD=root | ||
POSTGRES_DB=dj_crm | ||
DB_HOST=db | ||
DB_PORT=5432 |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# Execute startup scripts | ||
./wait-for-postgres.sh $DB_HOST | ||
python manage.py collectstatic --noinput | ||
python manage.py migrate | ||
python manage.py runserver 0.0.0.0:8000 |
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/bash | ||
# wait-for-postgres.sh | ||
|
||
set -e | ||
|
||
host="$1" | ||
shift | ||
cmd="$@" | ||
|
||
echo "Testing Postgres connection with psql ..." | ||
until PGPASSWORD=$POSTGRES_PASSWORD psql -h "$host" -U "postgres" -c '\q'; do | ||
#~ >&2 echo "Postgres is unavailable - sleeping" | ||
>&2 echo -n . | ||
sleep 1 | ||
done | ||
|
||
>&2 echo "Postgres is up - executing command" | ||
exec $cmd |