From 17739ff2630f0ead43065065f6b850d9ef2d5a9b Mon Sep 17 00:00:00 2001 From: "Nikita P. Shupeyko" Date: Wed, 9 May 2018 12:58:37 +0300 Subject: [PATCH] Refactor POSTGRES_PORT env --- {{cookiecutter.project_slug}}/.envs/.local/.postgres | 1 + {{cookiecutter.project_slug}}/.envs/.production/.postgres | 1 + .../compose/production/django/entrypoint.sh | 5 +++-- .../compose/production/postgres/maintenance/backup | 1 + .../compose/production/postgres/maintenance/restore | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.envs/.local/.postgres b/{{cookiecutter.project_slug}}/.envs/.local/.postgres index 5b115017..f190db8e 100644 --- a/{{cookiecutter.project_slug}}/.envs/.local/.postgres +++ b/{{cookiecutter.project_slug}}/.envs/.local/.postgres @@ -1,6 +1,7 @@ # PostgreSQL # ------------------------------------------------------------------------------ POSTGRES_HOST=postgres +POSTGRES_PORT=5432 POSTGRES_DB={{ cookiecutter.project_slug }} POSTGRES_USER=!!!SET POSTGRES_USER!!! POSTGRES_PASSWORD=!!!SET POSTGRES_PASSWORD!!! diff --git a/{{cookiecutter.project_slug}}/.envs/.production/.postgres b/{{cookiecutter.project_slug}}/.envs/.production/.postgres index 5b115017..f190db8e 100644 --- a/{{cookiecutter.project_slug}}/.envs/.production/.postgres +++ b/{{cookiecutter.project_slug}}/.envs/.production/.postgres @@ -1,6 +1,7 @@ # PostgreSQL # ------------------------------------------------------------------------------ POSTGRES_HOST=postgres +POSTGRES_PORT=5432 POSTGRES_DB={{ cookiecutter.project_slug }} POSTGRES_USER=!!!SET POSTGRES_USER!!! POSTGRES_PASSWORD=!!!SET POSTGRES_PASSWORD!!! diff --git a/{{cookiecutter.project_slug}}/compose/production/django/entrypoint.sh b/{{cookiecutter.project_slug}}/compose/production/django/entrypoint.sh index a995867f..74242bde 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/entrypoint.sh +++ b/{{cookiecutter.project_slug}}/compose/production/django/entrypoint.sh @@ -14,7 +14,7 @@ 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}:5432/${POSTGRES_DB}" +export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}" postgres_ready() { python << END @@ -27,7 +27,8 @@ try: dbname="${POSTGRES_DB}", user="${POSTGRES_USER}", password="${POSTGRES_PASSWORD}", - host="${POSTGRES_HOST}" + host="${POSTGRES_HOST}", + port="${POSTGRES_PORT}", ) except psycopg2.OperationalError: sys.exit(-1) diff --git a/{{cookiecutter.project_slug}}/compose/production/postgres/maintenance/backup b/{{cookiecutter.project_slug}}/compose/production/postgres/maintenance/backup index 31c59b2b..ee0c9d63 100644 --- a/{{cookiecutter.project_slug}}/compose/production/postgres/maintenance/backup +++ b/{{cookiecutter.project_slug}}/compose/production/postgres/maintenance/backup @@ -26,6 +26,7 @@ if [[ "${POSTGRES_USER}" == "postgres" ]]; then fi export PGHOST="${POSTGRES_HOST}" +export PGPORT="${POSTGRES_PORT}" export PGUSER="${POSTGRES_USER}" export PGPASSWORD="${POSTGRES_PASSWORD}" export PGDATABASE="${POSTGRES_DB}" diff --git a/{{cookiecutter.project_slug}}/compose/production/postgres/maintenance/restore b/{{cookiecutter.project_slug}}/compose/production/postgres/maintenance/restore index 3d4f46c8..9661ca7f 100644 --- a/{{cookiecutter.project_slug}}/compose/production/postgres/maintenance/restore +++ b/{{cookiecutter.project_slug}}/compose/production/postgres/maintenance/restore @@ -38,6 +38,7 @@ if [[ "${POSTGRES_USER}" == "postgres" ]]; then fi export PGHOST="${POSTGRES_HOST}" +export PGPORT="${POSTGRES_PORT}" export PGUSER="${POSTGRES_USER}" export PGPASSWORD="${POSTGRES_PASSWORD}" export PGDATABASE="${POSTGRES_DB}"