diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ee9c3d0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM postgres:9.6 +COPY create-multiple-postgresql-databases.sh /docker-entrypoint-initdb.d/ diff --git a/README.md b/README.md index 85c72ef..3c0cd1f 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ 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 @@ -28,3 +30,21 @@ Clone the repository, mount its directory as a volume into - 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=