From d3707c65fe55db365b57aaf964a1d2651bf96d7b Mon Sep 17 00:00:00 2001 From: ole Date: Fri, 26 May 2023 14:47:26 +0200 Subject: [PATCH 1/2] [sc-11462] cloned docker-postgresql-multiple-databases and edited the script --- create-multiple-postgresql-databases.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/create-multiple-postgresql-databases.sh b/create-multiple-postgresql-databases.sh index aa665fa..7aa5abc 100755 --- a/create-multiple-postgresql-databases.sh +++ b/create-multiple-postgresql-databases.sh @@ -5,11 +5,10 @@ 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; + GRANT ALL PRIVILEGES ON DATABASE $database TO $POSTGRES_USER; EOSQL } From 45fbe32ac517a3dd1f5946578a673c4152f3b097 Mon Sep 17 00:00:00 2001 From: ole Date: Fri, 26 May 2023 15:11:47 +0200 Subject: [PATCH 2/2] [sc-11462] trying to make it work 4 --- Dockerfile | 2 +- README.md | 34 ++++++++-------------------------- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index ee9c3d0..5801186 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,2 @@ -FROM postgres:9.6 +FROM postgres:latest COPY create-multiple-postgresql-databases.sh /docker-entrypoint-initdb.d/ diff --git a/README.md b/README.md index d4b6a15..7486925 100644 --- a/README.md +++ b/README.md @@ -20,34 +20,16 @@ mechanism. Clone the repository, mount its directory as a volume into `/docker-entrypoint-initdb.d` and declare database names separated by commas in `POSTGRES_MULTIPLE_DATABASES` environment variable as follows -(`docker-compose` syntax): +(`github actions` syntax): - myapp-postgresql: - image: postgres:9.6.2 + postgres: + image: postgres:12 volumes: - - ../docker-postgresql-multiple-databases:/docker-entrypoint-initdb.d - environment: - - POSTGRES_MULTIPLE_DATABASES: db1,db2 - - POSTGRES_USER: myapp - - POSTGRES_PASSWORD: - -### 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: - - 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: - - myapp-postgresql: - image: eu.gcr.io/your-project/postgres-multi-db - environment: - - POSTGRES_MULTIPLE_DATABASES: db1,db2 - - POSTGRES_USER: myapp - - POSTGRES_PASSWORD: + - docker-postgresql-multiple-databases:/docker-entrypoint-initdb.d + env: + POSTGRES_MULTIPLE_DATABASES: db1,db2 + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres ### Non-standard database names