Skip to content

Commit

Permalink
Merge pull request #28 from OpenDRR/docker-compose-drew-working
Browse files Browse the repository at this point in the history
Docker compose drew working
  • Loading branch information
jvanulde authored Aug 18, 2020
2 parents a177bc4 + ccc5d2a commit 032a13a
Show file tree
Hide file tree
Showing 22 changed files with 1,090 additions and 15,568 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

venv/
venv-pygeoapi/
.env
postgis/config.ini
python/config.ini
.DS_Store
83 changes: 22 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,71 +6,16 @@ REST API for OpenDRR data
## Setup in your local environment

### Prerequisites
- Elasticsearch 7.1.0+ running locally on port 9200
- E.g. http://localhost:9200/
- pygeoapi 0.7.0+ with Elasticsearch provider running locally
- E.g. http://localhost:5000/
- GeoJSON file(s)
- Sample provided in `sample-data` directory

### Setup

#### Deploy stack using Docker (Recommended)

##### Prerequisites

- Docker engine installed and running
- Curl installed

Easiest way to get the API stack setup is to use `deploy-stack.sh`. This script will deploy Elasticsearch and pygeoapi in Docker containers and load the sample data.

$ . deploy-stack.sh

#### Deploy stack components seperately

Install and start Elasticsearch on localhost

$ docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.6.2

> NOTE: if you have Elasticsearch installed on localhost already simply start it:
$ elasticsearch

Add `dataset` to pygeoapi using the Elasticsearch provider

datasets:
economic_loss:
title: Economic Loss
description: Economic consequences aggregated
keywords:
- earthquake
links:
- type: text/html
rel: canonical
title: information
href: http://www.riskprofiler.ca/
hreflang: en-US
extents:
spatial:
bbox: [-180,-90,180,90]
crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
temporal:
begin: 2011-11-11
end: null # or empty (either means open ended)
provider:
name: Elasticsearch
data: http://localhost:9200/economic_loss_agg_view
id_field: Sauid

> NOTE: a sample configuration is provided in `configuration/local.config.yml`
### Run docker-compose

Install and start pygeoapi on localhost
$ docker-compose up --build

$ . deploy-pygeoapi.sh

Run `load_es_data.py` script passing in a property that you want to use as the `id` (e.g. Sauid)

$ python scripts/load_es_data.py sample-data/dsra_sim6p8_cr2022_rlz_1_b0_economic_loss_agg_view.geojson Sauid
Once the stack is built (~20min) you can stop it with `Ctrl-C`. See below on how you can bring the stack back up without re-building.

### Verify that everything is working

Check Elasticsearch to ensure that the index was created

Expand All @@ -81,7 +26,7 @@ You should see something similar to:
health status index ...
green open economic_loss_agg_view XnIFL7LNTBWupGSXJOFjig ...

Check pygeoapi to make sure that the feature collection can be acccesed
Check pygeoapi to make sure that the feature collection can be accessed

$ http://localhost:5000/collections/economic_loss/items?f=json&limit=1

Expand Down Expand Up @@ -152,6 +97,8 @@ You should see something similar to:
"timeStamp": "2020-03-25T19:21:13.065240Z"
}

## Interacting with the endpoints

### Querying pygeoapi

Refer to the pygeoapi documentation for general guidance:
Expand Down Expand Up @@ -219,3 +166,17 @@ Refer to the pygeoapi documentation for general guidance:
]
}
}'

## Start/Stop the stack

Once the stack is built you only need to re-build when there is new data. The `docker-compose-run.yml` script is an override that you can use to run the built stack - it doesn't create the python container that pulls the latest code and data from GitHub to populate the stack.

To start the stack:

$ docker-compose -f docker-compose-run.yml start

To stop the stack:

$ docker-compose -f docker-compose-run.yml stop


112 changes: 0 additions & 112 deletions configuration/local.config.yml

This file was deleted.

72 changes: 0 additions & 72 deletions deploy-pygeoapi.sh

This file was deleted.

Loading

0 comments on commit 032a13a

Please sign in to comment.