From b8e9934a5e054782c249d8100cee4ca89077ef7b Mon Sep 17 00:00:00 2001 From: Cuong Nguyen Date: Sat, 19 May 2018 20:31:18 -0700 Subject: [PATCH 1/3] Removed creating user --- Dockerfile | 2 +- create-multiple-postgresql-databases.sh | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ee9c3d0..8f76803 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,2 @@ -FROM postgres:9.6 +FROM postgres COPY create-multiple-postgresql-databases.sh /docker-entrypoint-initdb.d/ diff --git a/create-multiple-postgresql-databases.sh b/create-multiple-postgresql-databases.sh index aa665fa..db656c0 100755 --- a/create-multiple-postgresql-databases.sh +++ b/create-multiple-postgresql-databases.sh @@ -5,11 +5,9 @@ set -u function create_user_and_database() { local database=$1 - echo " Creating user and database '$database'" + echo " Creating database '$database'" psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL - CREATE USER $database; CREATE DATABASE $database; - GRANT ALL PRIVILEGES ON DATABASE $database TO $database; EOSQL } From b9e617308c11a91c298ea61881f3798989c842a6 Mon Sep 17 00:00:00 2001 From: Cuong Nguyen Date: Sat, 19 May 2018 20:38:40 -0700 Subject: [PATCH 2/3] Shorten variable name --- create-multiple-postgresql-databases.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/create-multiple-postgresql-databases.sh b/create-multiple-postgresql-databases.sh index db656c0..46c19cb 100755 --- a/create-multiple-postgresql-databases.sh +++ b/create-multiple-postgresql-databases.sh @@ -11,9 +11,9 @@ function create_user_and_database() { EOSQL } -if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then - echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES" - for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do +if [ -n "$POSTGRES_MULTI_DB" ]; then + echo "Multiple database creation requested: $POSTGRES_MULTI_DB" + for db in $(echo $POSTGRES_MULTI_DB | tr ',' ' '); do create_user_and_database $db done echo "Multiple databases created" From fcb8024823bd3b55c2f550ed67fbc53c08d69dda Mon Sep 17 00:00:00 2001 From: Cuong Nguyen Date: Sat, 19 May 2018 20:53:38 -0700 Subject: [PATCH 3/3] Added instruction for pushing to Docker Hub Registry --- README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3db6ca3..56c5495 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,20 @@ Clone the repository, mount its directory as a volume into ### By building a custom image Clone the repository, build and push the image to your Docker repository, -for example for Google Private Repository do the following: +For Docker Hub Registry - docker build --tag=eu.gcr.io/your-project/postgres-multi-db . - gcloud docker -- push eu.gcr.io/your-project/postgres-multi-db +```sh +docker build -t /postgres-multi-db . +docker login +docker push /postgres-multi-db +``` + +For Google Private Repository do the following: + +```sh +docker build --tag=eu.gcr.io/your-project/postgres-multi-db . +gcloud docker -- push eu.gcr.io/your-project/postgres-multi-db +``` You still need to pass the `POSTGRES_MULTIPLE_DATABASES` environment variable to the container: