Skip to content

Commit a050390

Browse files
authored
Merge pull request #1 from jonhealy1/elasticsearch
Elasticsearch
2 parents 67cc6ff + f7c1af9 commit a050390

39 files changed

+3632
-1
lines changed

.github/pull_request_template.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
**Related Issue(s):** #
2+
3+
4+
**Description:**
5+
6+
7+
**PR Checklist:**
8+
9+
- [ ] Code is formatted and linted (run `pre-commit run --all-files`)
10+
- [ ] Tests pass (run `make test`)
11+
- [ ] Documentation has been updated to reflect changes, if applicable, and docs build successfully (run `make docs`)
12+
- [ ] Changes are added to the [CHANGELOG](https://github.com/stac-utils/pystac/blob/master/CHANGES.md).

.github/workflows/cicd.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: stac-fastapi-nosql
2+
on:
3+
push:
4+
branches: [ main ]
5+
pull_request:
6+
branches: [ main ]
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 10
12+
13+
services:
14+
mongo_db_service:
15+
image: mongo:3.6
16+
env:
17+
MONGO_INITDB_ROOT_USERNAME: dev
18+
MONGO_INITDB_ROOT_PASSWORD: stac
19+
ports:
20+
- 27018:27017
21+
22+
elasticsearch_db_service:
23+
image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2
24+
env:
25+
node.name: es01
26+
cluster.name: stac-cluster
27+
discovery.type: single-node
28+
network.host: 0.0.0.0
29+
http.port: 9200
30+
ES_JAVA_OPTS: -Xms512m -Xmx512m
31+
ports:
32+
- 9200:9200
33+
34+
steps:
35+
- name: Check out repository code
36+
uses: actions/checkout@v2
37+
38+
# Setup Python (faster than using Python container)
39+
- name: Setup Python
40+
uses: actions/setup-python@v2
41+
with:
42+
python-version: "3.8"
43+
44+
- name: Lint code
45+
uses: pre-commit/action@v2.0.0
46+
47+
- name: Install pipenv
48+
run: |
49+
python -m pip install --upgrade pipenv wheel
50+
51+
- name: Install mongo stac-fastapi
52+
run: |
53+
pip install ./stac_fastapi/mongo[dev,server]
54+
55+
- name: Install elasticsearch stac-fastapi
56+
run: |
57+
pip install ./stac_fastapi/elasticsearch[dev,server]
58+
59+
- name: Run test suite
60+
run: |
61+
cd stac_fastapi/mongo && pipenv run pytest -svvv
62+
env:
63+
ENVIRONMENT: testing
64+
MONGO_USER: dev
65+
MONGO_PASS: stac
66+
MONGO_PORT: 27018
67+
MONGO_HOST: localhost
68+
69+
- name: Run test suite
70+
run: |
71+
cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
72+
env:
73+
ENVIRONMENT: testing
74+
ES_USER: dev
75+
ES_PASS: stac
76+
ES_PORT: 9200
77+
ES_HOST: 172.17.0.1

Dockerfile.elasticsearch

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM python:3.8-slim as base
2+
3+
FROM base as builder
4+
# Any python libraries that require system libraries to be installed will likely
5+
# need the following packages in order to build
6+
RUN apt-get update && apt-get install -y build-essential git
7+
8+
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
9+
10+
ARG install_dev_dependencies=true
11+
12+
WORKDIR /app
13+
14+
# Install stac_fastapi.types
15+
COPY . /app
16+
17+
ENV PATH=$PATH:/install/bin
18+
19+
RUN mkdir -p /install && \
20+
pip install -e ./stac_fastapi/elasticsearch[dev,server]

Makefile

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
APP_HOST ?= 0.0.0.0
33
APP_PORT ?= 8080
44
EXTERNAL_APP_PORT ?= ${APP_PORT}
5+
6+
run_es = docker-compose -f docker-compose.elasticsearch.yml \
7+
run \
8+
-p ${EXTERNAL_APP_PORT}:${APP_PORT} \
9+
-e PY_IGNORE_IMPORTMISMATCH=1 \
10+
-e APP_HOST=${APP_HOST} \
11+
-e APP_PORT=${APP_PORT} \
12+
app-elasticsearch
13+
514
run_mongo = docker-compose -f docker-compose.mongo.yml \
615
run \
716
-p ${EXTERNAL_APP_PORT}:${APP_PORT} \
@@ -10,28 +19,48 @@ run_mongo = docker-compose -f docker-compose.mongo.yml \
1019
-e APP_PORT=${APP_PORT} \
1120
app-mongo
1221

22+
.PHONY: es-image
23+
es-image:
24+
docker-compose -f docker-compose.elasticsearch.yml build
25+
1326
.PHONY: mongo-image
1427
mongo-image:
1528
docker-compose -f docker-compose.mongo.yml build
1629

30+
.PHONY: docker-run-es
31+
docker-run-es: es-image
32+
$(run_es)
33+
1734
.PHONY: docker-run-mongo
1835
docker-run-mongo: mongo-image
1936
$(run_mongo)
2037

38+
.PHONY: docker-shell-es
39+
docker-shell-es:
40+
$(run_es) /bin/bash
41+
2142
.PHONY: docker-shell-mongo
2243
docker-shell-mongo:
2344
$(run_mongo) /bin/bash
2445

46+
.PHONY: test-es
47+
test-es:
48+
$(run_es) /bin/bash -c 'export && ./scripts/wait-for-it.sh elasticsearch:9200 && cd /app/stac_fastapi/elasticsearch/tests/ && pytest'
49+
2550
.PHONY: test-mongo
2651
test-mongo:
2752
$(run_mongo) /bin/bash -c 'export && cd /app/stac_fastapi/mongo/tests/ && pytest'
2853

54+
.PHONY: run-es-database
55+
run-es-database:
56+
docker-compose -f docker-compose.elasticsearch.yml run --rm elasticsearch
57+
2958
.PHONY: run-mongo-database
3059
run-mongo-database:
3160
docker-compose -f docker-compose.mongo.yml run --rm mongo_db
3261

3362
.PHONY: test
34-
test: test-sqlalchemy test-pgstac test-mongo
63+
test: test-elasticsearch test-mongo
3564

3665
.PHONY: pybase-install
3766
pybase-install:
@@ -40,6 +69,10 @@ pybase-install:
4069
pip install -e ./stac_fastapi/types[dev] && \
4170
pip install -e ./stac_fastapi/extensions[dev]
4271

72+
.PHONY: es-install
73+
es-install: pybase-install
74+
pip install -e ./stac_fastapi/elasticsearch[dev,server]
75+
4376
.PHONY: mongo-install
4477
mongo-install: pybase-install
4578
pip install -e ./stac_fastapi/mongo[dev,server]

docker-compose.elasticsearch.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: '3'
2+
3+
services:
4+
app-elasticsearch:
5+
container_name: stac-fastapi-es
6+
image: stac-utils/stac-fastapi
7+
restart: always
8+
build:
9+
context: .
10+
dockerfile: Dockerfile.elasticsearch
11+
platform: linux/amd64
12+
environment:
13+
- APP_HOST=0.0.0.0
14+
- APP_PORT=8083
15+
- RELOAD=false
16+
- ENVIRONMENT=local
17+
- WEB_CONCURRENCY=10
18+
- ES_USER=dev
19+
- ES_PASS=stac
20+
- ES_PORT=9200
21+
- ES_HOST=172.17.0.1
22+
ports:
23+
- "8083:8083"
24+
volumes:
25+
- ./stac_fastapi:/app/stac_fastapi
26+
- ./scripts:/app/scripts
27+
depends_on:
28+
- elasticsearch
29+
command:
30+
bash -c "./scripts/wait-for-it-es.sh es-container:9200 && python -m stac_fastapi.elasticsearch.app"
31+
32+
elasticsearch:
33+
container_name: es-container
34+
image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2
35+
environment:
36+
node.name: es01
37+
cluster.name: stac-cluster
38+
discovery.type: single-node
39+
network.host: 0.0.0.0
40+
http.port: 9200
41+
ES_JAVA_OPTS: -Xms512m -Xmx512m
42+
ports:
43+
- 9200:9200
44+
45+
networks:
46+
default:
47+
name: stac-fastapi-network

0 commit comments

Comments
 (0)