From bfa5f4a5330e519616312e07cdca628c8383ae85 Mon Sep 17 00:00:00 2001 From: Felix Sun Date: Fri, 21 Jun 2019 12:56:55 +0800 Subject: [PATCH 01/11] change to 9 --- Dockerfile | 2 +- push_docker.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100755 push_docker.sh diff --git a/Dockerfile b/Dockerfile index ee9c3d0..6129650 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,2 @@ -FROM postgres:9.6 +FROM postgres:9 COPY create-multiple-postgresql-databases.sh /docker-entrypoint-initdb.d/ diff --git a/push_docker.sh b/push_docker.sh new file mode 100755 index 0000000..363160f --- /dev/null +++ b/push_docker.sh @@ -0,0 +1,2 @@ +docker build -t theplant/postgresmd:9 . +docker push theplant/postgresmd:9 From 10ad818c996db309aa3bf559d91c4be9367084d2 Mon Sep 17 00:00:00 2001 From: Felix Sun Date: Tue, 25 Jun 2019 10:06:34 +0800 Subject: [PATCH 02/11] Update README.md --- README.md | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 3db6ca3..94bfc41 100644 --- a/README.md +++ b/README.md @@ -15,35 +15,19 @@ mechanism. ## Usage -### By mounting a volume - -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): - - myapp-postgresql: - image: postgres:9.6.2 - 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 + docker build --tag=theplant/postgresmd:9. + gcloud docker -- push theplant/postgresmd:9 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 + image: theplant/postgresmd:9 environment: - POSTGRES_MULTIPLE_DATABASES=db1,db2 - POSTGRES_USER=myapp From 7231bcc432048999411a28f4226af7a27b5b9aa5 Mon Sep 17 00:00:00 2001 From: Felix Sun Date: Tue, 25 Jun 2019 10:06:57 +0800 Subject: [PATCH 03/11] Update README.md --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 94bfc41..3d5f7ad 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,6 @@ mechanism. ## Usage -### 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=theplant/postgresmd:9. - gcloud docker -- push theplant/postgresmd:9 - You still need to pass the `POSTGRES_MULTIPLE_DATABASES` environment variable to the container: From 183680dcbadd41946cc00dc7cac398cc56ffab56 Mon Sep 17 00:00:00 2001 From: sunfmin Date: Wed, 25 Dec 2019 13:41:34 +0800 Subject: [PATCH 04/11] add 9, 10, 11 --- Dockerfile | 3 ++- push_docker.sh | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6129650..2ec3387 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,3 @@ -FROM postgres:9 +ARG VER=9 +FROM postgres:$VER COPY create-multiple-postgresql-databases.sh /docker-entrypoint-initdb.d/ diff --git a/push_docker.sh b/push_docker.sh index 363160f..a0a2e8c 100755 --- a/push_docker.sh +++ b/push_docker.sh @@ -1,2 +1,8 @@ -docker build -t theplant/postgresmd:9 . +docker build -t theplant/postgresmd:9 --build-arg VER=9 . docker push theplant/postgresmd:9 + +docker build -t theplant/postgresmd:10 --build-arg VER=10 . +docker push theplant/postgresmd:10 + +docker build -t theplant/postgresmd:11 --build-arg VER=11 . +docker push theplant/postgresmd:11 From c895a7ea2d894e974c7c6ef5658bd4e859a8467e Mon Sep 17 00:00:00 2001 From: tnclong Date: Fri, 27 Mar 2020 15:00:22 +0800 Subject: [PATCH 05/11] optional POSTGRES_EXTENSIONS --- create-multiple-postgresql-databases.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/create-multiple-postgresql-databases.sh b/create-multiple-postgresql-databases.sh index aa665fa..ff6412f 100755 --- a/create-multiple-postgresql-databases.sh +++ b/create-multiple-postgresql-databases.sh @@ -13,10 +13,27 @@ function create_user_and_database() { EOSQL } +function create_extension_on_database() { + local database=$1 + local extension=$2 + echo " Creating extension '$extension'" + psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -d $database <<-EOSQL + CREATE EXTENSION IF NOT EXISTS $extension; +EOSQL +} + if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES" for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do create_user_and_database $db + + if [ ! -z "${POSTGRES_EXTENSIONS-}" ]; then + echo " Extensions creation requested: $db" + for ext in $(echo $POSTGRES_EXTENSIONS | tr ',' ' '); do + create_extension_on_database $db $ext + done + echo " Extensions created" + fi done echo "Multiple databases created" fi From f1699320e28bd92047cf5552b203cd04f184a196 Mon Sep 17 00:00:00 2001 From: tnclong Date: Thu, 6 Aug 2020 09:40:27 +0800 Subject: [PATCH 06/11] build based on postgis/postgis https://postgis.net/docs/postgis_installation.html#create_new_db_extensions --- Dockerfile | 2 +- push_docker.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ec3387..2af149a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,3 @@ ARG VER=9 -FROM postgres:$VER +FROM postgis/postgis:$VER COPY create-multiple-postgresql-databases.sh /docker-entrypoint-initdb.d/ diff --git a/push_docker.sh b/push_docker.sh index a0a2e8c..99051ca 100755 --- a/push_docker.sh +++ b/push_docker.sh @@ -1,8 +1,8 @@ -docker build -t theplant/postgresmd:9 --build-arg VER=9 . +docker build -t theplant/postgresmd:9 --build-arg VER=9.6-3.0 . docker push theplant/postgresmd:9 -docker build -t theplant/postgresmd:10 --build-arg VER=10 . +docker build -t theplant/postgresmd:10 --build-arg VER=10-3.0 . docker push theplant/postgresmd:10 -docker build -t theplant/postgresmd:11 --build-arg VER=11 . +docker build -t theplant/postgresmd:11 --build-arg VER=11-3.0 . docker push theplant/postgresmd:11 From ebb41a1e80e6b92ede03f606a6dd6f1104cd03a8 Mon Sep 17 00:00:00 2001 From: Haochuan Date: Thu, 13 Oct 2022 17:03:36 +0900 Subject: [PATCH 07/11] Migrate DockerHub to ECR --- README.md | 14 +++++++++++++- push_docker.sh | 12 ++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3d5f7ad..1103024 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,24 @@ You still need to pass the `POSTGRES_MULTIPLE_DATABASES` environment variable to the container: myapp-postgresql: - image: theplant/postgresmd:9 + image: public.ecr.aws/theplant/postgresmd:9 environment: - POSTGRES_MULTIPLE_DATABASES=db1,db2 - POSTGRES_USER=myapp - POSTGRES_PASSWORD= +## Push image + +Please assume AWS IAM `developer` role before push image +``` +[alias.main-developer] +arn = "arn:aws:iam::562055475000:role/developer" +``` + +``` +aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/theplant +``` + ### Non-standard database names If you need to use non-standard database names (hyphens, uppercase letters etc), quote them in `POSTGRES_MULTIPLE_DATABASES`: diff --git a/push_docker.sh b/push_docker.sh index 99051ca..4890a63 100755 --- a/push_docker.sh +++ b/push_docker.sh @@ -1,8 +1,8 @@ -docker build -t theplant/postgresmd:9 --build-arg VER=9.6-3.0 . -docker push theplant/postgresmd:9 +docker build -t public.ecr.aws/theplant/postgresmd:9 --build-arg VER=9.6-3.0 . +docker push public.ecr.aws/theplant/postgresmd:9 -docker build -t theplant/postgresmd:10 --build-arg VER=10-3.0 . -docker push theplant/postgresmd:10 +docker build -t public.ecr.aws/theplant/postgresmd:10 --build-arg VER=10-3.0 . +docker push public.ecr.aws/theplant/postgresmd:10 -docker build -t theplant/postgresmd:11 --build-arg VER=11-3.0 . -docker push theplant/postgresmd:11 +docker build -t public.ecr.aws/theplant/postgresmd:11 --build-arg VER=11-3.0 . +docker push public.ecr.aws/theplant/postgresmd:11 From d5897a5c7f0a734c53148fbbaa882e1e0243eed9 Mon Sep 17 00:00:00 2001 From: Haochuan Date: Fri, 25 Nov 2022 18:07:44 +0900 Subject: [PATCH 08/11] Add Postgres v12 - 15 --- push_docker.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/push_docker.sh b/push_docker.sh index 4890a63..8bd162d 100755 --- a/push_docker.sh +++ b/push_docker.sh @@ -6,3 +6,15 @@ docker push public.ecr.aws/theplant/postgresmd:10 docker build -t public.ecr.aws/theplant/postgresmd:11 --build-arg VER=11-3.0 . docker push public.ecr.aws/theplant/postgresmd:11 + +docker build -t public.ecr.aws/theplant/postgresmd:12 --build-arg VER=12-3.3 . +docker push public.ecr.aws/theplant/postgresmd:12 + +docker build -t public.ecr.aws/theplant/postgresmd:13 --build-arg VER=13-3.3 . +docker push public.ecr.aws/theplant/postgresmd:13 + +docker build -t public.ecr.aws/theplant/postgresmd:14 --build-arg VER=14-3.3 . +docker push public.ecr.aws/theplant/postgresmd:14 + +docker build -t public.ecr.aws/theplant/postgresmd:15 --build-arg VER=15-3.3 . +docker push public.ecr.aws/theplant/postgresmd:15 \ No newline at end of file From 8e4ebc2739749a817feaf09b36f210303ff7d9dd Mon Sep 17 00:00:00 2001 From: Haochuan Date: Mon, 28 Nov 2022 20:17:56 +0900 Subject: [PATCH 09/11] Delete deprecated pg versions --- README.md | 2 +- push_docker.sh | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/README.md b/README.md index 1103024..1cba44d 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ You still need to pass the `POSTGRES_MULTIPLE_DATABASES` environment variable to the container: myapp-postgresql: - image: public.ecr.aws/theplant/postgresmd:9 + image: public.ecr.aws/theplant/postgresmd:13 environment: - POSTGRES_MULTIPLE_DATABASES=db1,db2 - POSTGRES_USER=myapp diff --git a/push_docker.sh b/push_docker.sh index 8bd162d..6aa62ca 100755 --- a/push_docker.sh +++ b/push_docker.sh @@ -1,12 +1,3 @@ -docker build -t public.ecr.aws/theplant/postgresmd:9 --build-arg VER=9.6-3.0 . -docker push public.ecr.aws/theplant/postgresmd:9 - -docker build -t public.ecr.aws/theplant/postgresmd:10 --build-arg VER=10-3.0 . -docker push public.ecr.aws/theplant/postgresmd:10 - -docker build -t public.ecr.aws/theplant/postgresmd:11 --build-arg VER=11-3.0 . -docker push public.ecr.aws/theplant/postgresmd:11 - docker build -t public.ecr.aws/theplant/postgresmd:12 --build-arg VER=12-3.3 . docker push public.ecr.aws/theplant/postgresmd:12 From 82d69799a9c494253d518debbc7a23a890758796 Mon Sep 17 00:00:00 2001 From: Jaden Teng Date: Mon, 27 Oct 2025 13:45:46 +0800 Subject: [PATCH 10/11] update and add new postgresmd images --- push_docker.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/push_docker.sh b/push_docker.sh index 6aa62ca..2937710 100755 --- a/push_docker.sh +++ b/push_docker.sh @@ -1,11 +1,20 @@ docker build -t public.ecr.aws/theplant/postgresmd:12 --build-arg VER=12-3.3 . docker push public.ecr.aws/theplant/postgresmd:12 -docker build -t public.ecr.aws/theplant/postgresmd:13 --build-arg VER=13-3.3 . +docker build -t public.ecr.aws/theplant/postgresmd:13 --build-arg VER=13-3.5 . docker push public.ecr.aws/theplant/postgresmd:13 -docker build -t public.ecr.aws/theplant/postgresmd:14 --build-arg VER=14-3.3 . +docker build -t public.ecr.aws/theplant/postgresmd:14 --build-arg VER=14-3.5 . docker push public.ecr.aws/theplant/postgresmd:14 -docker build -t public.ecr.aws/theplant/postgresmd:15 --build-arg VER=15-3.3 . -docker push public.ecr.aws/theplant/postgresmd:15 \ No newline at end of file +docker build -t public.ecr.aws/theplant/postgresmd:15 --build-arg VER=15-3.5 . +docker push public.ecr.aws/theplant/postgresmd:15 + +docker build -t public.ecr.aws/theplant/postgresmd:16 --build-arg VER=16-3.5 . +docker push public.ecr.aws/theplant/postgresmd:16 + +docker build -t public.ecr.aws/theplant/postgresmd:17 --build-arg VER=17-3.5 . +docker push public.ecr.aws/theplant/postgresmd:17 + +docker build -t public.ecr.aws/theplant/postgresmd:18 --build-arg VER=18-3.6 . +docker push public.ecr.aws/theplant/postgresmd:18 From 8f71cb8108fc06297e3f4dfbb1d2df2b2e49febd Mon Sep 17 00:00:00 2001 From: Jaden Teng Date: Mon, 27 Oct 2025 13:46:31 +0800 Subject: [PATCH 11/11] remove deprecated postgresmd:12 --- push_docker.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/push_docker.sh b/push_docker.sh index 2937710..a44c994 100755 --- a/push_docker.sh +++ b/push_docker.sh @@ -1,6 +1,3 @@ -docker build -t public.ecr.aws/theplant/postgresmd:12 --build-arg VER=12-3.3 . -docker push public.ecr.aws/theplant/postgresmd:12 - docker build -t public.ecr.aws/theplant/postgresmd:13 --build-arg VER=13-3.5 . docker push public.ecr.aws/theplant/postgresmd:13