Skip to content

Commit

Permalink
update postgis whenever using a postgres docker image for jenkins
Browse files Browse the repository at this point in the history
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 <[email protected]>
Tested-by: Jenkins
Product-Review: Shahbaz Javeed <[email protected]>
QA-Review: Shahbaz Javeed <[email protected]>
  • Loading branch information
sjaveed committed Nov 16, 2017
1 parent 40dc05e commit af717ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 0 additions & 1 deletion build/docker-compose/postgres/9.5/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 /
4 changes: 0 additions & 4 deletions build/docker-compose/postgres/9.5/zz-run-update-postgis.sh

This file was deleted.

10 changes: 10 additions & 0 deletions build/docker_composer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit af717ee

Please sign in to comment.