From ec6fb380f3d3f74fbc12a38815a4072d691ec9cd Mon Sep 17 00:00:00 2001 From: Colton Loftus <70598503+C-Loftus@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:35:01 -0400 Subject: [PATCH] Updates to the sparql provider to match the mainstem query (#22) * Query Mainstems and Gages with SPARQL provider (7261757324) * Update SPARQL provider * Use pygeoapi root image * updates to the sparql provider to match the mainstem query * updated docker compose * update readme * Update pygeoapi.config.yml Co-authored-by: Benjamin Webb <40066515+webb-ben@users.noreply.github.com> * Update docker-compose.yml Co-authored-by: Benjamin Webb <40066515+webb-ben@users.noreply.github.com> * reversions * indent * indent again for diff * update sparql config * change back to error * add indent * Update pygeoapi.config.yml --------- Co-authored-by: Benjamin Webb <40066515+webb-ben@users.noreply.github.com> --- .gitignore | 3 + Dockerfile | 5 +- README.md | 18 ++++- docker-compose.yml | 30 +++++++- .../templates/collections/items/item.html | 2 +- .../templates/jsonld/hu06.jsonld | 2 +- pygeoapi.config.yml | 69 +++++++++---------- 7 files changed, 82 insertions(+), 47 deletions(-) diff --git a/.gitignore b/.gitignore index 68bc17f..eaec569 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,6 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + + +*.sql.gz \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2bd7e12..d4eeb47 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,11 @@ FROM geopython/pygeoapi:latest #pygeoapi last updated 2023-07-31 -#add requirements and mods -COPY ./pygeoapi.config.yml /pygeoapi/local.config.yml - # COPY ./schemas.opengis.net /opt/schemas.opengis.net COPY ./pygeoapi-skin-dashboard /skin-dashboard +COPY ./pygeoapi.config.yml /pygeoapi/local.config.yml + RUN pip3 install https://github.com/cgs-earth/pygeoapi-plugins/archive/refs/heads/master.zip COPY ./sitemap /sitemap diff --git a/README.md b/README.md index 57da026..0ddfe32 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,23 @@ These reference features are intended to be ["community reference locations"](ht ## Install -Generate a SQL Dump of the Hydroshare resource using [Hydrodump Action](https://github.com/cgs-earth/hydrodump-action). - -Then use docker compose to bring up the containers: +Use docker compose to bring up the containers: ``` docker compose up -d database docker compose up -d pygeoapi ``` + +Then generate a SQL Dump of the Hydroshare resource using [Hydrodump Action](https://github.com/cgs-earth/hydrodump-action). + +``` +docker compose up -d hydrodump +``` + +If you have a local hydrodump `reference.sql.gz` file, you can use that instead of regenerating the dump using + +``` +docker compose up -d local +``` + + diff --git a/docker-compose.yml b/docker-compose.yml index e510062..8981e6c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,11 @@ -# dont need this anymore, but useful for test deployment -# requires separate service providing postgres database services: pygeoapi: build: . container_name: reference-geoconnex-us ports: - 5000:80 + volumes: + - ./pygeoapi.config.yml:/pygeoapi/local.config.yml env_file: - .env @@ -14,6 +14,8 @@ services: image: postgis/postgis:14-3.2-alpine env_file: - .env + volumes: + - db_data:/var/lib/postgresql/data hydrodump: container_name: hydrodump @@ -21,3 +23,27 @@ services: command: ["hydrodump", "run"] env_file: - .env + + local: + # Instead of using a remote hydrodump, you can source a local database dump, reference.sql.gz + container_name: local + image: postgis/postgis:14-3.2-alpine + depends_on: + - database + volumes: + - ./reference.sql.gz:/docker-entrypoint-initdb.d/reference.sql.gz + entrypoint: > + sh -c " + export PGPASSWORD=${POSTGRES_PASSWORD} && \ + echo 'Waiting for database to be ready...' && \ + while ! pg_isready -h ${POSTGRES_HOST} -U ${POSTGRES_USER} -d ${POSTGRES_DB}; do + sleep 1 + done && \ + echo 'Database is ready. Starting migration...' && \ + gunzip -c /docker-entrypoint-initdb.d/reference.sql.gz | psql -h ${POSTGRES_HOST} -U ${POSTGRES_USER} -d ${POSTGRES_DB} + " + env_file: + - .env + +volumes: + db_data: diff --git a/pygeoapi-skin-dashboard/templates/collections/items/item.html b/pygeoapi-skin-dashboard/templates/collections/items/item.html index 0de346c..1b69afc 100644 --- a/pygeoapi-skin-dashboard/templates/collections/items/item.html +++ b/pygeoapi-skin-dashboard/templates/collections/items/item.html @@ -172,4 +172,4 @@