Setting up postgis on Gitlab CI

postgresql

#1

I’ve being trying to setup gitlab CI with my django project. The project uses postgis extension. After all this setup I still get the error that postgis.control file could not be found

$ export PGPASSWORD=$POSTGRES_PASSWORD
$ psql -c "CREATE EXTENSION IF NOT EXISTS postgis;" -d $POSTGRES_DB -U $POSTGRES_USER -h "postgres"
ERROR:  could not open extension control file "/usr/share/postgresql/11/extension/postgis.control": No such file or directory
ERROR: Job failed: exit code 1

Here is my .gitlab-ci.yml file

image: python:3.6

stages:
  - test

services:
  - mdillon/postgis
  - postgres

variables:
  POSTGRES_DB: my_db
  POSTGRES_USER: my_user
  POSTGRES_PASSWORD: ""
  TESTFOLDER: "myapp/apps/api myapp/apps/logger"
  DATABASE_URL: "postgres://my_user:@mdillon-postgis/my_db"

test:
  stage: test
  image: mdillon/postgis
  before_script:
    - apt-get update -qy
    - export PGPASSWORD=$POSTGRES_PASSWORD
    - psql -c "CREATE EXTENSION IF NOT EXISTS postgis;" -d $POSTGRES_DB -U    $POSTGRES_USER -h "postgres"
    - psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;" -d $POSTGRES_DB -U $POSTGRES_USER -h "postgres"
    - apt-get install -y openjdk-8-jre-headless libjpeg-dev zlib1g-dev software-properties-common ghostscript libxslt1-dev binutils libproj-dev libgdal-dev gdal-bin memcached libmemcached-dev 
    - export DEBIAN_FRONTEND=noninteractive;
    - pip install --upgrade pip
    - pip install -r requirements/base.pip
    - pip install flake8
  script:
    - python manage.py test $TESTFOLDER --noinput --settings=myapp.settings.gitlab_ci --parallel 4 --verbosity=2
  only:
    - master

#3

I’ve Figured it out, totally my fault :man_facepalming: I should have read more on gitlab’s services to find out


#4

@mensaah Can you post the working config file. Having this same issue. Thanks!


#5

I have problem trying to do the same. If you solved it, could you share me you gitlab-ci please. thx