diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e28da570..eb84e7fc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,7 +6,7 @@ on: - "v*.*.*" # Triggers when a tag like 'v3.2.0' is pushed jobs: - build-and-publish: + build-and-publish-pypi: name: Build and Publish Packages runs-on: ubuntu-latest @@ -58,3 +58,69 @@ jobs: # Publish to PyPI twine upload dist/* + + build-and-push-images: + name: Build and Push Docker Images + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for Elasticsearch image + id: meta-es + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository_owner }}/stac-fastapi-es + tags: | + type=raw,value=latest + type=ref,event=tag + + - name: Push Elasticsearch image + uses: docker/build-push-action@v6 + with: + context: . + file: dockerfiles/Dockerfile.ci.es + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta-es.outputs.tags }} + labels: ${{ steps.meta-es.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Extract metadata for OpenSearch image + id: meta-os + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository_owner }}/stac-fastapi-os + tags: | + type=raw,value=latest + type=ref,event=tag + + - name: Push OpenSearch image + uses: docker/build-push-action@v6 + with: + context: . + file: dockerfiles/Dockerfile.ci.os + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta-os.outputs.tags }} + labels: ${{ steps.meta-os.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 95c427a7..2469eb46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [v3.2.1] - 2024-11-14 + +### Added +- Added `dockerfiles/Dockerfile.ci.os` and `dockerfiles/Dockerfile.ci.es`, along with their respective entrypoints [#311](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/311) + +### Changed +- Updated the `publish.yml` workflow to include Docker image publishing to GitHub Container Registry [#311](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/311) +- Improved the README with detailed descriptions of the new Docker images, providing guidance for images. [#311](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/311) - Aggregation ElasticSearch `total_count` bugfix, moved aggregation text to docs. [#314](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/314) ## [v3.2.0] - 2024-10-09 diff --git a/README.md b/README.md index 0ff4f254..1783422c 100644 --- a/README.md +++ b/README.md @@ -43,17 +43,24 @@ or pip install stac_fastapi.opensearch ``` -## Build Elasticsearch API backend +### To install and run via pre-built Docker Images + +We provide ready-to-use Docker images through GitHub Container Registry ([ElasticSearch](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pkgs/container/stac-fastapi-es) and [OpenSearch](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pkgs/container/stac-fastapi-os) backends). You can easily pull and run these images: ```shell -docker-compose up elasticsearch -docker-compose build app-elasticsearch +# For Elasticsearch backend +docker pull ghcr.io/stac-utils/stac-fastapi-es:latest + +# For OpenSearch backend +docker pull ghcr.io/stac-utils/stac-fastapi-os:latest ``` -## Running Elasticsearch API on localhost:8080 +## Run Elasticsearch API backend on localhost:8080 + +You need to ensure [**Docker Compose**](https://docs.docker.com/compose/install/) or [**Podman Compose**](https://podman-desktop.io/docs/compose) installed and running on your machine. In the follwoing command instead of `docker-compose` you can use `podman-compose` as well. ```shell -docker-compose up app-elasticsearch +docker-compose up elasticsearch app-elasticsearch ``` By default, docker-compose uses Elasticsearch 8.x and OpenSearch 2.11.1. @@ -66,6 +73,35 @@ OPENSEARCH_VERSION=2.11.0 ``` The most recent Elasticsearch 7.x versions should also work. See the [opensearch-py docs](https://github.com/opensearch-project/opensearch-py/blob/main/COMPATIBILITY.md) for compatibility information. +#### **Configuration reference keys:** + +You can customize additional settings in your `.env` file: +###### Key variables to configure: + +| Variable | Description | Default | Required | +|------------------------------|--------------------------------------------------------------------------------------|--------------------------|---------------------------------------------------------------------------------------------| +| `ES_HOST` | Hostname for external Elasticsearch/OpenSearch. | `localhost` | Optional | +| `ES_PORT` | Port for Elasticsearch/OpenSearch. | `9200` (ES) / `9202` (OS)| Optional | +| `ES_USE_SSL` | Use SSL for connecting to Elasticsearch/OpenSearch. | `false` | Optional | +| `ES_VERIFY_CERTS` | Verify SSL certificates when connecting. | `false` | Optional | +| `STAC_FASTAPI_TITLE` | Title of the API in the documentation. | `stac-fastapi-elasticsearch` or `stac-fastapi-opensearch` | Optional | +| `STAC_FASTAPI_DESCRIPTION` | Description of the API in the documentation. | N/A | Optional | +| `STAC_FASTAPI_VERSION` | API version. | `2.1` | Optional | +| `APP_HOST` | Server bind address. | `0.0.0.0` | Optional | +| `APP_PORT` | Server port. | `8080` | Optional | +| `ENVIRONMENT` | Runtime environment. | `local` | Optional | +| `WEB_CONCURRENCY` | Number of worker processes. | `10` | Optional | +| `RELOAD` | Enable auto-reload for development. | `true` | Optional | +| `STAC_FASTAPI_RATE_LIMIT` | API rate limit per client. | `200/minute` | Optional | +| `BACKEND` | Tests-related variable | `elasticsearch` or `opensearch` based on the backend | Optional | +| `ELASTICSEARCH_VERSION` | ElasticSearch version | `7.17.1` | Optional | +| `OPENSEARCH_VERSION` | OpenSearch version | `2.11.0` | Optional | + +> [!NOTE] +> The variables `ES_HOST`, `ES_PORT`, `ES_USE_SSL`, and `ES_VERIFY_CERTS` apply to both Elasticsearch and OpenSearch backends, so there is no need to rename the key names to `OS_` even if you're using OpenSearch. + +## Interacting with the API + To create a new Collection: ```shell diff --git a/dockerfiles/Dockerfile.ci.es b/dockerfiles/Dockerfile.ci.es new file mode 100644 index 00000000..a6fb6a53 --- /dev/null +++ b/dockerfiles/Dockerfile.ci.es @@ -0,0 +1,19 @@ +FROM python:3.12-slim + +WORKDIR /app + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + gcc \ + curl \ + && apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +COPY . /app/ + +RUN pip3 install --no-cache-dir -e ./stac_fastapi/core && \ + pip3 install --no-cache-dir ./stac_fastapi/elasticsearch[server] + +USER root + +CMD ["python", "-m", "stac_fastapi.elasticsearch.app"] \ No newline at end of file diff --git a/dockerfiles/Dockerfile.ci.os b/dockerfiles/Dockerfile.ci.os new file mode 100644 index 00000000..a046a3b6 --- /dev/null +++ b/dockerfiles/Dockerfile.ci.os @@ -0,0 +1,19 @@ +FROM python:3.12-slim + +WORKDIR /app + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + gcc \ + curl \ + && apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +COPY . /app/ + +RUN pip3 install --no-cache-dir -e ./stac_fastapi/core && \ + pip3 install --no-cache-dir ./stac_fastapi/opensearch[server] + +USER root + +CMD ["python", "-m", "stac_fastapi.opensearch.app"] \ No newline at end of file diff --git a/stac_fastapi/core/stac_fastapi/core/version.py b/stac_fastapi/core/stac_fastapi/core/version.py index fad2b4e4..59d4d1a3 100644 --- a/stac_fastapi/core/stac_fastapi/core/version.py +++ b/stac_fastapi/core/stac_fastapi/core/version.py @@ -1,2 +1,2 @@ """library version.""" -__version__ = "3.2.0" +__version__ = "3.2.1" diff --git a/stac_fastapi/elasticsearch/setup.py b/stac_fastapi/elasticsearch/setup.py index a23cbe7c..9239d4fa 100644 --- a/stac_fastapi/elasticsearch/setup.py +++ b/stac_fastapi/elasticsearch/setup.py @@ -6,7 +6,7 @@ desc = f.read() install_requires = [ - "stac-fastapi.core==3.2.0", + "stac-fastapi.core==3.2.1", "elasticsearch[async]==8.11.0", "elasticsearch-dsl==8.11.0", "uvicorn", diff --git a/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/version.py b/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/version.py index fad2b4e4..59d4d1a3 100644 --- a/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/version.py +++ b/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/version.py @@ -1,2 +1,2 @@ """library version.""" -__version__ = "3.2.0" +__version__ = "3.2.1" diff --git a/stac_fastapi/opensearch/setup.py b/stac_fastapi/opensearch/setup.py index 2cd43da3..3ea0b9ca 100644 --- a/stac_fastapi/opensearch/setup.py +++ b/stac_fastapi/opensearch/setup.py @@ -6,7 +6,7 @@ desc = f.read() install_requires = [ - "stac-fastapi.core==3.2.0", + "stac-fastapi.core==3.2.1", "opensearch-py==2.4.2", "opensearch-py[async]==2.4.2", "uvicorn", diff --git a/stac_fastapi/opensearch/stac_fastapi/opensearch/version.py b/stac_fastapi/opensearch/stac_fastapi/opensearch/version.py index fad2b4e4..59d4d1a3 100644 --- a/stac_fastapi/opensearch/stac_fastapi/opensearch/version.py +++ b/stac_fastapi/opensearch/stac_fastapi/opensearch/version.py @@ -1,2 +1,2 @@ """library version.""" -__version__ = "3.2.0" +__version__ = "3.2.1"