Installing Postgis


We’re setting up the environment as follows:

version: 2
executorType: docker
  - image: ruby:latest
  - image: postgres:9.3.11
      - POSTGRES_USER=postgres
      - POSTGRES_DB=xyz_test

… and we’re getting an error trying to activate the postgis extension:

ActiveRecord::StatementInvalid: PG::UndefinedFile: ERROR:  could not open extension control file "/usr/share/postgresql/9.3/extension/postgis.control": No such file or directory

The alternative would be to install postgres and postgis via apt-get, but it would be easier to use an image if there are plans to support this (?).


We’ve had quite a few people have luck with using the postgis Docker image. Is this an option for you?


I second what Lev said. The Dockerfile for that project is pretty plain and simple. If you’re looking for more flexibility with Postgres versions, that Dockerfile is a good place to start.


Thanks for the help guys - we have it up and running with that docker image :slight_smile:


I’m attempting to use that postgis image as well and actually use it fine in kubernetes. But when running tests in circle-ci 2 I get an error that the role for my user, which I set in the env to POSTGRES_USER, does not exist. Is there anything additional anyone had to do to get it working? Shouldn’t it be running the script at startup that creates the user?


Can you specify which version of the image you are using? I have not seen this before, would love to try to reproduce it.


I’m using tag 9.5.


Thanks! I will try on my own and see if I can see whats going on, will get back to you soon.


Any luck reproducing? I get the same with 9.6, so I suspect it is something about my setup that is the issue :).

Do you have any suggestions on how to debug? I don’t see a way that I’d be able to connect to the postgis container to see how it is configured.


I switched to using the user postgres and a blank password but I am still stuck since it isn’t creating the database:

  - image: mdillon/postgis:9.5
      - POSTGRES_USER=postgres

results in database \"nucleus\" does not exist"


There shouldn’t be another postgres listening on, right? Only if I start a container that runs postgres should it be available at all?


facepalm I think I see what I was doing wrong! I corrected my yaml to:

  - image: mdillon/postgis:9.5
      - POSTGRES_USER=postgres
      - PGUSER=postgres
      - POSTGRES_DB=nucleus

Sorry for the confusion :slight_smile:


That actually took me a minute to understand what was different in your posts too. Thanks for sharing.

For other users looking at the two config snippets, the first one lumps together all the config pairs into one YAML array element. The latter puts one “VAR=VALUE” string into a YAML array element.

Both are valid YAML and will pass through from CircleCI to Docker, where it gets parsed by the container on startup. The first one will likely set the Postgres user to “postgres PGUSER=postgres POSTGRES_DB=nucleus POSTGRES_PASSWORD=”

I find it helpful to visually check a parsed circle.yml with a yaml parser like