From 3b341e8a97b272d3c395ad8990285e8eb2eb1ae3 Mon Sep 17 00:00:00 2001 From: ManUtopiK Date: Thu, 20 Oct 2022 23:07:28 +0200 Subject: [PATCH] Add postgis --- composes/postgres/Dockerfile | 5 +++++ composes/postgres/init-data.sh | 4 ++++ composes/postgres/postgres.yml | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 composes/postgres/Dockerfile diff --git a/composes/postgres/Dockerfile b/composes/postgres/Dockerfile new file mode 100644 index 0000000..4224d7b --- /dev/null +++ b/composes/postgres/Dockerfile @@ -0,0 +1,5 @@ +FROM postgres:14.5-bullseye + +RUN apt-get update && apt-get install -y postgresql-14-postgis-3 + +CMD ["/usr/local/bin/docker-entrypoint.sh","postgres"] \ No newline at end of file diff --git a/composes/postgres/init-data.sh b/composes/postgres/init-data.sh index a8b1917..779b0b5 100644 --- a/composes/postgres/init-data.sh +++ b/composes/postgres/init-data.sh @@ -1,6 +1,10 @@ #!/bin/bash set -e; +# Add postgis +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL + CREATE EXTENSION postgis; +EOSQL if [ -n "${POSTGRES_NON_ROOT_USER:-}" ] && [ -n "${POSTGRES_NON_ROOT_PASSWORD:-}" ]; then psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL diff --git a/composes/postgres/postgres.yml b/composes/postgres/postgres.yml index 405ca1b..0ce1a2d 100644 --- a/composes/postgres/postgres.yml +++ b/composes/postgres/postgres.yml @@ -1,7 +1,9 @@ services: postgres: container_name: $APP_NAME-postgres - image: postgres:14 + build: + context: . + dockerfile: Dockerfile restart: always environment: - POSTGRES_DB=${POSTGRES_DB:-$APP_NAME}