From 9621c46392924e46e6ddd20c7c2da6429dbba624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 4 Oct 2016 17:33:51 -0500 Subject: [PATCH] [REF] Odoo 8.0-10.0: do not require linking environment variables The entry points of the Odoo docker images require the presence of the following environment variables: - DB_PORT_5432_TCP_ADDR - DB_PORT_5432_TCP_PORT - DB_ENV_POSTGRES_USER - DB_ENV_POSTGRES_PASSWORD We use them to set the PGHOST, PGPORT, PGUSER and PGPASSWORD environment variable that will then be read by Odoo in order to connect to the database server. As the first ones are automatically created by Docker when we use the linking system, it's not possible to run Odoo without the linking system and, for example, with Docker compose. In order to make it work with Docker compose and keep the backward compatibility with the linking system, we have to provide sane fallbacks to the assignation of the PGHOST, PGPORT, PGUSER and PGPASSWORD environment variable. We do that in this commit by defaulting the assignation of the postgres host to "db" and the port to "5432" because, if you follow our image documentation, that's what you get. We also introduce the handling of two others environment variable in the Odoo entry point: POSTGRES_USER and POSTGRES_PASSWORD. They will be used as fallbacks for DB_ENV_POSTGRES_USER and DB_ENV_POSTGRES_PASSWORD. --- 10.0/entrypoint.sh | 8 ++++---- 8.0/entrypoint.sh | 8 ++++---- 9.0/entrypoint.sh | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/10.0/entrypoint.sh b/10.0/entrypoint.sh index fbb8f37..c1e4ecb 100755 --- a/10.0/entrypoint.sh +++ b/10.0/entrypoint.sh @@ -3,10 +3,10 @@ set -e # set odoo database host, port, user and password -: ${PGHOST:=$DB_PORT_5432_TCP_ADDR} -: ${PGPORT:=$DB_PORT_5432_TCP_PORT} -: ${PGUSER:=${DB_ENV_POSTGRES_USER:='postgres'}} -: ${PGPASSWORD:=$DB_ENV_POSTGRES_PASSWORD} +: ${PGHOST:=${DB_PORT_5432_TCP_ADDR:='db'}} +: ${PGPORT:=${DB_PORT_5432_TCP_PORT:=5432}} +: ${PGUSER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='postgres'}}} +: ${PGPASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=$POSTGRES_PASSWORD}} export PGHOST PGPORT PGUSER PGPASSWORD case "$1" in diff --git a/8.0/entrypoint.sh b/8.0/entrypoint.sh index 8ec01b4..ce41742 100755 --- a/8.0/entrypoint.sh +++ b/8.0/entrypoint.sh @@ -3,10 +3,10 @@ set -e # set odoo database host, port, user and password -: ${PGHOST:=$DB_PORT_5432_TCP_ADDR} -: ${PGPORT:=$DB_PORT_5432_TCP_PORT} -: ${PGUSER:=${DB_ENV_POSTGRES_USER:='postgres'}} -: ${PGPASSWORD:=$DB_ENV_POSTGRES_PASSWORD} +: ${PGHOST:=${DB_PORT_5432_TCP_ADDR:='db'}} +: ${PGPORT:=${DB_PORT_5432_TCP_PORT:=5432}} +: ${PGUSER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='postgres'}}} +: ${PGPASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=$POSTGRES_PASSWORD}} export PGHOST PGPORT PGUSER PGPASSWORD case "$1" in diff --git a/9.0/entrypoint.sh b/9.0/entrypoint.sh index 8ec01b4..ce41742 100755 --- a/9.0/entrypoint.sh +++ b/9.0/entrypoint.sh @@ -3,10 +3,10 @@ set -e # set odoo database host, port, user and password -: ${PGHOST:=$DB_PORT_5432_TCP_ADDR} -: ${PGPORT:=$DB_PORT_5432_TCP_PORT} -: ${PGUSER:=${DB_ENV_POSTGRES_USER:='postgres'}} -: ${PGPASSWORD:=$DB_ENV_POSTGRES_PASSWORD} +: ${PGHOST:=${DB_PORT_5432_TCP_ADDR:='db'}} +: ${PGPORT:=${DB_PORT_5432_TCP_PORT:=5432}} +: ${PGUSER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='postgres'}}} +: ${PGPASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=$POSTGRES_PASSWORD}} export PGHOST PGPORT PGUSER PGPASSWORD case "$1" in