From af717ee42855c374cfbddd284b49da7dabc2aa1c Mon Sep 17 00:00:00 2001 From: Shahbaz Javeed Date: Wed, 15 Nov 2017 14:12:55 -0500 Subject: [PATCH] update postgis whenever using a postgres docker image for jenkins This might help mitigate the dreaded postgis error we've been seeing (OperationalError: could not access file "$libdir/postgis-X.X) while allowing us to continue to use our docker volume caching mechanism in jenkins Change-Id: I9ae8f660709ce4e261ac064ce294740264166882 Reviewed-on: https://gerrit.instructure.com/133015 Reviewed-by: Simon Williams Tested-by: Jenkins Product-Review: Shahbaz Javeed QA-Review: Shahbaz Javeed --- build/docker-compose/postgres/9.5/Dockerfile | 1 - .../postgres/9.5/zz-run-update-postgis.sh | 4 ---- build/docker_composer.rb | 10 ++++++++++ 3 files changed, 10 insertions(+), 5 deletions(-) delete mode 100755 build/docker-compose/postgres/9.5/zz-run-update-postgis.sh diff --git a/build/docker-compose/postgres/9.5/Dockerfile b/build/docker-compose/postgres/9.5/Dockerfile index fba1d81a6c64d..7725d3fb02c6b 100644 --- a/build/docker-compose/postgres/9.5/Dockerfile +++ b/build/docker-compose/postgres/9.5/Dockerfile @@ -8,6 +8,5 @@ RUN echo "max_locks_per_transaction = 640" >> /usr/share/postgresql/$PG_MAJOR/po # needs to be named .sh for it to get run COPY /create-dbs.sh /docker-entrypoint-initdb.d/ -COPY /zz-run-update-postgis.sh /docker-entrypoint-initdb.d/ COPY /wait-for-it / diff --git a/build/docker-compose/postgres/9.5/zz-run-update-postgis.sh b/build/docker-compose/postgres/9.5/zz-run-update-postgis.sh deleted file mode 100755 index 7738472ac2e7e..0000000000000 --- a/build/docker-compose/postgres/9.5/zz-run-update-postgis.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -export POSTGRES_USER=postgres -/usr/local/bin/update-postgis.sh diff --git a/build/docker_composer.rb b/build/docker_composer.rb index 85c27828b23ad..2aa47401d0eb0 100644 --- a/build/docker_composer.rb +++ b/build/docker_composer.rb @@ -111,6 +111,7 @@ def launch_services docker_compose "build #{services.join(" ")}" prepare_volumes start_services + update_postgis db_prepare unless using_snapshot? # already set up, just need to migrate end @@ -129,6 +130,15 @@ def prepare_volumes wait_for "data_loader" end + # To prevent errors similar to: OperationalError: could not access file "$libdir/postgis-X.X + # These happen when your docker image expects one version of PostGIS but the volume has a different one. This + # should noop if there's no mismatch in the version of PostGIS + # https://hub.docker.com/r/mdillon/postgis/ + def update_postgis + puts "Updating PostGIS" + docker "exec --user postgres #{ENV["COMPOSE_PROJECT_NAME"]}_postgres_1 update-postgis.sh" + end + def db_prepare # pg db setup happens in create-dbs.sh (when we docker-compose up), # but cassandra doesn't have a similar hook