Installing Postgis


#1

We’re setting up the environment as follows:

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

… 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
: CREATE EXTENSION IF NOT EXISTS "postgis"

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 (?).


#2

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


#3

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.


#4

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


#5

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?


#6

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


#7

I’m using tag 9.5.


#8

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


#9

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.


#10

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
    env:
      - POSTGRES_USER=postgres
        PGUSER=postgres
        POSTGRES_DB=nucleus
        POSTGRES_PASSWORD=

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


#11

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


#12

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

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

Sorry for the confusion :slight_smile:


#13

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 http://yaml-online-parser.appspot.com/


#14