Skip to content

pycsw with Postgres

Dan Nowacki edited this page Mar 6, 2020 · 1 revision

This is the modern (2020) way we are running pycsw on gamone. After lots of issues with sqlite as the db we moved to Postgres.

  1. Modify docker-compose.yml following general format at https://github.com/axiom-data-science/docker-pycsw. This is what the relevant snippet looks like:
    image: kartoza/postgis:11.0-2.5
    stop_signal: SIGINT
    environment:
      POSTGRES_DBNAME: pycsw
      POSTGRES_USER: pycsw
      POSTGRES_PASS: pycsw
    volumes:
      - /opt/docker/postgres/data/db:/var/lib/postgresql

  pycsw:
    image: axiom/docker-pycsw:latest
    volumes:
      - /opt/docker/pycsw/usgs-cmg.cfg:/opt/pycsw/default.cfg
      - /opt/docker/pycsw/force:/force 
      - /opt/docker/pycsw/export:/export
      - /opt/docker/pycsw/store:/store

    ports:
      - "8000:8000"
    depends_on:
      - postgres
  1. Update usgs-cmg.cfg to use postgres as the database. Insert this text at the relevant line, and comment out the sqlite line: database=postgresql://pycsw:pycsw@postgres/pycsw

  2. Migrate directories. I moved the old pycsw directory to a backup and created a new, empty /opt/docker/pycsw directory. In here I placed the usgs-cmg.cfg file (updated with the postgres line above) and the export, force, store directores; otherwise the container won't start.

  3. Start Postgres

docker-compose up -d postgres
  1. Restart pycsw
docker-compose stop pycsw
docker-compose up -d pycsw