Skip to content

Commit

Permalink
fix: make POSTGRES_PORT optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ngurenyaga committed Jul 12, 2021
1 parent 0e534b7 commit a853ed2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 28 deletions.
3 changes: 2 additions & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@
"USER": env.str("POSTGRES_USER"),
"PASSWORD": env.str("POSTGRES_PASSWORD"),
"HOST": env.str("POSTGRES_HOST"),
"PORT": env.str("POSTGRES_PORT"),
"PORT": env.str("POSTGRES_PORT", None),
"ENGINE": "django.db.backends.postgresql",
"ATOMIC_REQUESTS": True,
}
}
print(f"databases: {DATABASES}")

# URLS
# ------------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,3 @@ def require_env(name: str) -> str:
require_env("POSTGRES_USER")
require_env("POSTGRES_PASSWORD")
require_env("POSTGRES_HOST")
require_env("POSTGRES_PORT")
26 changes: 0 additions & 26 deletions entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,6 @@ set -o errexit
set -o pipefail
set -o nounset

postgres_ready() {
python << END
import sys
import psycopg2
try:
psycopg2.connect(
dbname="${POSTGRES_DB}",
user="${POSTGRES_USER}",
password="${POSTGRES_PASSWORD}",
host="${POSTGRES_HOST}",
port="${POSTGRES_PORT}",
)
except psycopg2.OperationalError:
sys.exit(-1)
sys.exit(0)
END
}
until postgres_ready; do
>&2 echo 'Waiting for PostgreSQL to become available...'
sleep 1
done
>&2 echo 'PostgreSQL is available'

python /app/manage.py migrate
>&2 echo 'Ran database migrations...'

Expand Down

0 comments on commit a853ed2

Please sign in to comment.