Skip to content

Commit

Permalink
fix: omit port when connecting to Cloud SQL via Cloud Run
Browse files Browse the repository at this point in the history
  • Loading branch information
ngurenyaga committed Jul 12, 2021
1 parent 9a65989 commit a3316d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 77 deletions.
8 changes: 7 additions & 1 deletion entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ if [ -z "${POSTGRES_USER}" ]; then
base_postgres_image_default_user='postgres'
export POSTGRES_USER="${base_postgres_image_default_user}"
fi
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"

# omit the port when running on App Engine, Cloud Run etc
if [ -z "${INSTANCE_CONNECTION_NAME}"]; then
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
else
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}/${POSTGRES_DB}"
fi

postgres_ready() {
python << END
Expand Down
76 changes: 0 additions & 76 deletions local.yml

This file was deleted.

0 comments on commit a3316d4

Please sign in to comment.