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 <simon@instructure.com>
Tested-by: Jenkins
Product-Review: Shahbaz Javeed <sjaveed@instructure.com>
QA-Review: Shahbaz Javeed <sjaveed@instructure.com>
This commit is contained in:
Shahbaz Javeed 2017-11-15 14:12:55 -05:00
parent 40dc05e0fe
commit af717ee428
3 changed files with 10 additions and 5 deletions

View File

@ -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 /

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
export POSTGRES_USER=postgres
/usr/local/bin/update-postgis.sh

View File

@ -111,6 +111,7 @@ class DockerComposer
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 @@ class DockerComposer
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