diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..98a7c03b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + - package-ecosystem: pip + directory: "/.github/workflows" + schedule: + interval: daily + - package-ecosystem: pip + directory: "/stac_fastapi/elasticsearch" + schedule: + interval: daily diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 76a1ab6d..54da137c 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -12,8 +12,8 @@ jobs: services: - elasticsearch_db_service: - image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2 + elasticsearch_7_svc: + image: docker.elastic.co/elasticsearch/elasticsearch:7.17.1 env: node.name: es01 cluster.name: stac-cluster @@ -23,7 +23,19 @@ jobs: ES_JAVA_OPTS: -Xms512m -Xmx512m ports: - 9200:9200 - + +# elasticsearch_8_svc: +# image: docker.elastic.co/elasticsearch/elasticsearch:8.1.0 +# env: +# node.name: es01 +# cluster.name: stac-cluster +# discovery.type: single-node +# network.host: 0.0.0.0 +# http.port: 9200 +# ES_JAVA_OPTS: -Xms512m -Xmx512m +# ports: +# - 9200:9200 + steps: - name: Check out repository code uses: actions/checkout@v2 @@ -44,8 +56,8 @@ jobs: - name: Install elasticsearch stac-fastapi run: | pip install ./stac_fastapi/elasticsearch[dev,server] - - - name: Run test suite + + - name: Run test suite against Elasticsearch 7.x run: | cd stac_fastapi/elasticsearch && pipenv run pytest -svvv env: @@ -53,4 +65,14 @@ jobs: ES_USER: dev ES_PASS: stac ES_PORT: 9200 - ES_HOST: 172.17.0.1 \ No newline at end of file + ES_HOST: 172.17.0.1 +# +# - name: Run test suite against Elasticsearch 8.x +# run: | +# cd stac_fastapi/elasticsearch && pipenv run pytest -svvv +# env: +# ENVIRONMENT: testing +# ES_USER: dev +# ES_PASS: stac +# ES_PORT: 9400 +# ES_HOST: 172.17.0.1 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e5ad4d1..164a0a6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added +- Support for Elasticsearch 7.x or 8.x + ### Fixed ### Changed @@ -19,4 +21,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Removed + [Unreleased]: diff --git a/Makefile b/Makefile index d504c9bf..bb0a8c34 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ docker-shell: .PHONY: test test: $(run_es) /bin/bash -c 'export && ./scripts/wait-for-it-es.sh elasticsearch:9200 && cd /app/stac_fastapi/elasticsearch/tests/ && pytest' + docker-compose down .PHONY: run-database run-database: diff --git a/README.md b/README.md index 132d283e..b1713ea1 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,15 @@ docker-compose build docker-compose up ``` +By default, docker-compose uses Elasticsearch 7.x. If you wish to use a different version, put the following in a +file named `.env` in the same directory you run docker-compose from: + +```shell +ELASTICSEARCH_VERSION=7.12.0 +``` + +TBD: how to run this with 8.x with a password enabled and TLS. + To create a new Collection: ```shell diff --git a/docker-compose.yml b/docker-compose.yml index 25227f49..f66d6289 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,7 +32,7 @@ services: elasticsearch: container_name: es-container - image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2 + image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.17.1} environment: node.name: es01 cluster.name: stac-cluster @@ -41,8 +41,4 @@ services: http.port: 9200 ES_JAVA_OPTS: -Xms512m -Xmx512m ports: - - 9200:9200 - -networks: - default: - name: stac-fastapi-es-network + - "9200:9200" diff --git a/stac_fastapi/elasticsearch/setup.py b/stac_fastapi/elasticsearch/setup.py index 3088351a..13b82d3e 100644 --- a/stac_fastapi/elasticsearch/setup.py +++ b/stac_fastapi/elasticsearch/setup.py @@ -13,8 +13,8 @@ "stac-fastapi.api==2.3.0", "stac-fastapi.extensions==2.3.0", "fastapi-utils", - "elasticsearch[async]", - "elasticsearch-dsl", + "elasticsearch[async]==7.17.1", + "elasticsearch-dsl==7.4.0", "pystac[validation]", "uvicorn", ] diff --git a/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py b/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py index 66ba592e..2345f6f9 100644 --- a/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py +++ b/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py @@ -22,6 +22,7 @@ class ElasticsearchSettings(ApiSettings): @property def create_client(self): """Create es client.""" - # try: - client = Elasticsearch([{"host": str(DOMAIN), "port": str(PORT)}]) - return client + return Elasticsearch( + [{"host": str(DOMAIN), "port": str(PORT)}], + headers={"accept": "application/vnd.elasticsearch+json; compatible-with=7"}, + )