Rgeo-proj4 & postgis config for CircleCi 2.0

ruby
postgresql
2.0

#1

Hi!

I’m trying to migrate a rails app that uses postgis and rgeo to CirlceCi 2.0. I’m using the following config

# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/ruby:2.5.1-node-browsers
        environment:
          RAILS_ENV: test
          PGHOST: 127.0.0.1
          PGUSER: root
      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      - image: circleci/postgres:10.3-postgis-ram
        environment:
          POSTGRES_USER: root
          POSTGRES_DB: circle-test_test

    working_directory: ~/repo

I’m getting the following errors because the rgeo-proj4 gem isn’t being setup correctly.

Failure/Error: MERC_FACTORY = RGeo::Geographic.projected_factory(buffer_resolution: 8, projection_proj4: "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs", projection_srid: 3857)

RGeo::Error::UnsupportedOperation:
  Coordinate system 'proj4' is not supported.

The rgeo-proj4 depends on native extensions (proj4) that are installed as part of the postgis image as far as I know. Perhaps the the gems are being installed before the postgis environment has been set up. I’m fairly clueless at this stuff but I tried reversing the order of the images but that definitely didn’t work

It would be pretty standard to use rgeo-proj4 when using postgis with ruby so I’m surprised there are issues. I must be doing something strange. If anyone can help I would be very grateful

Conor


#2

Hello,
If you need any custom dependencies in your database image what I would suggest doing is creating a custom Docker image using ours as the base image.

We have a short and easy video tutorial on how to do that in our docs:

https://circleci.com/docs/2.0/custom-images/#how-to-customize-docker-images-for-circleci-20-video-tutorial

You can add the install step for the required dependencies for your database and use this image instead.