text: # docker-compose build
  version: '2.1'
  volumes:
    dbbackups:
    postgis-data:
  
  services:
  
    db:
      image: kartoza/postgis:12.0
      volumes:
        - postgis-data:/var/lib/postgresql
        - dbbackups:/backups
      environment:
        # If you need to create multiple database you can add coma separated databases eg gis,data
        - POSTGRES_DB=gis
        - POSTGRES_USER=docker
        - POSTGRES_PASS=docker
        - ALLOW_IP_RANGE=0.0.0.0/0
        # Add extensions you need to be enabled by default in the DB. Default are the five specified below
        - POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting
      ports:
        - 25432:5432
      restart: on-failure
      healthcheck:
        test: "exit 0"
  
    dbbackups:
      image: kartoza/pg-backup:12.0
      hostname: pg-backups
      volumes:
        - dbbackups:/backups
      environment:
        - DUMPPREFIX=PG_db
        - POSTGRES_USER=docker
        - POSTGRES_PASS=docker
        - POSTGRES_PORT=5432
        - POSTGRES_HOST=db
        - POSTGRES_DBNAME=gis
      restart: on-failure
      depends_on:
        db:
          condition: service_healthy
  