Skip to content

Commit 2fceed1

Browse files
mo-dkrzjonhealy1
andauthored
add build push docker image image in the publish ci (stac-utils#311)
**Related Issue(s):** - # **Description:** Since I needed to have this docker images of elastic search and open search, I added a new publish docker image step in publish.yml ping @jonhealy1 **PR Checklist:** - [x] Code is formatted and linted (run `pre-commit run --all-files`) - [x] Tests pass (run `make test`) - [x] Documentation has been updated to reflect changes, if applicable - [x] Changes are added to the changelog --------- Co-authored-by: Jonathan Healy <[email protected]>
1 parent 5ab4c4b commit 2fceed1

File tree

10 files changed

+159
-11
lines changed

10 files changed

+159
-11
lines changed

.github/workflows/publish.yml

+67-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- "v*.*.*" # Triggers when a tag like 'v3.2.0' is pushed
77

88
jobs:
9-
build-and-publish:
9+
build-and-publish-pypi:
1010
name: Build and Publish Packages
1111
runs-on: ubuntu-latest
1212

@@ -58,3 +58,69 @@ jobs:
5858
5959
# Publish to PyPI
6060
twine upload dist/*
61+
62+
build-and-push-images:
63+
name: Build and Push Docker Images
64+
runs-on: ubuntu-latest
65+
permissions:
66+
contents: read
67+
packages: write
68+
69+
steps:
70+
- name: Checkout repository
71+
uses: actions/checkout@v4
72+
73+
- name: Set up QEMU
74+
uses: docker/setup-qemu-action@v3
75+
76+
- name: Set up Docker Buildx
77+
uses: docker/setup-buildx-action@v3
78+
79+
- name: Log in to GitHub Container Registry
80+
uses: docker/login-action@v3
81+
with:
82+
registry: ghcr.io
83+
username: ${{ github.actor }}
84+
password: ${{ secrets.GITHUB_TOKEN }}
85+
86+
- name: Extract metadata for Elasticsearch image
87+
id: meta-es
88+
uses: docker/metadata-action@v5
89+
with:
90+
images: ghcr.io/${{ github.repository_owner }}/stac-fastapi-es
91+
tags: |
92+
type=raw,value=latest
93+
type=ref,event=tag
94+
95+
- name: Push Elasticsearch image
96+
uses: docker/build-push-action@v6
97+
with:
98+
context: .
99+
file: dockerfiles/Dockerfile.ci.es
100+
platforms: linux/amd64,linux/arm64
101+
push: true
102+
tags: ${{ steps.meta-es.outputs.tags }}
103+
labels: ${{ steps.meta-es.outputs.labels }}
104+
cache-from: type=gha
105+
cache-to: type=gha,mode=max
106+
107+
- name: Extract metadata for OpenSearch image
108+
id: meta-os
109+
uses: docker/metadata-action@v5
110+
with:
111+
images: ghcr.io/${{ github.repository_owner }}/stac-fastapi-os
112+
tags: |
113+
type=raw,value=latest
114+
type=ref,event=tag
115+
116+
- name: Push OpenSearch image
117+
uses: docker/build-push-action@v6
118+
with:
119+
context: .
120+
file: dockerfiles/Dockerfile.ci.os
121+
platforms: linux/amd64,linux/arm64
122+
push: true
123+
tags: ${{ steps.meta-os.outputs.tags }}
124+
labels: ${{ steps.meta-os.outputs.labels }}
125+
cache-from: type=gha
126+
cache-to: type=gha,mode=max

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
## [v3.2.1] - 2024-11-14
11+
12+
### Added
13+
- 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)
14+
15+
### Changed
16+
- 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)
17+
- 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)
1018
- Aggregation ElasticSearch `total_count` bugfix, moved aggregation text to docs. [#314](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/314)
1119

1220
## [v3.2.0] - 2024-10-09

README.md

+41-5
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,24 @@ or
4343
pip install stac_fastapi.opensearch
4444
```
4545

46-
## Build Elasticsearch API backend
46+
### To install and run via pre-built Docker Images
47+
48+
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:
4749

4850
```shell
49-
docker-compose up elasticsearch
50-
docker-compose build app-elasticsearch
51+
# For Elasticsearch backend
52+
docker pull ghcr.io/stac-utils/stac-fastapi-es:latest
53+
54+
# For OpenSearch backend
55+
docker pull ghcr.io/stac-utils/stac-fastapi-os:latest
5156
```
5257

53-
## Running Elasticsearch API on localhost:8080
58+
## Run Elasticsearch API backend on localhost:8080
59+
60+
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.
5461

5562
```shell
56-
docker-compose up app-elasticsearch
63+
docker-compose up elasticsearch app-elasticsearch
5764
```
5865

5966
By default, docker-compose uses Elasticsearch 8.x and OpenSearch 2.11.1.
@@ -66,6 +73,35 @@ OPENSEARCH_VERSION=2.11.0
6673
```
6774
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.
6875

76+
#### **Configuration reference keys:**
77+
78+
You can customize additional settings in your `.env` file:
79+
###### Key variables to configure:
80+
81+
| Variable | Description | Default | Required |
82+
|------------------------------|--------------------------------------------------------------------------------------|--------------------------|---------------------------------------------------------------------------------------------|
83+
| `ES_HOST` | Hostname for external Elasticsearch/OpenSearch. | `localhost` | Optional |
84+
| `ES_PORT` | Port for Elasticsearch/OpenSearch. | `9200` (ES) / `9202` (OS)| Optional |
85+
| `ES_USE_SSL` | Use SSL for connecting to Elasticsearch/OpenSearch. | `false` | Optional |
86+
| `ES_VERIFY_CERTS` | Verify SSL certificates when connecting. | `false` | Optional |
87+
| `STAC_FASTAPI_TITLE` | Title of the API in the documentation. | `stac-fastapi-elasticsearch` or `stac-fastapi-opensearch` | Optional |
88+
| `STAC_FASTAPI_DESCRIPTION` | Description of the API in the documentation. | N/A | Optional |
89+
| `STAC_FASTAPI_VERSION` | API version. | `2.1` | Optional |
90+
| `APP_HOST` | Server bind address. | `0.0.0.0` | Optional |
91+
| `APP_PORT` | Server port. | `8080` | Optional |
92+
| `ENVIRONMENT` | Runtime environment. | `local` | Optional |
93+
| `WEB_CONCURRENCY` | Number of worker processes. | `10` | Optional |
94+
| `RELOAD` | Enable auto-reload for development. | `true` | Optional |
95+
| `STAC_FASTAPI_RATE_LIMIT` | API rate limit per client. | `200/minute` | Optional |
96+
| `BACKEND` | Tests-related variable | `elasticsearch` or `opensearch` based on the backend | Optional |
97+
| `ELASTICSEARCH_VERSION` | ElasticSearch version | `7.17.1` | Optional |
98+
| `OPENSEARCH_VERSION` | OpenSearch version | `2.11.0` | Optional |
99+
100+
> [!NOTE]
101+
> 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.
102+
103+
## Interacting with the API
104+
69105
To create a new Collection:
70106

71107
```shell

dockerfiles/Dockerfile.ci.es

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM python:3.12-slim
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update && \
6+
apt-get install -y --no-install-recommends \
7+
gcc \
8+
curl \
9+
&& apt-get clean && \
10+
rm -rf /var/lib/apt/lists/*
11+
12+
COPY . /app/
13+
14+
RUN pip3 install --no-cache-dir -e ./stac_fastapi/core && \
15+
pip3 install --no-cache-dir ./stac_fastapi/elasticsearch[server]
16+
17+
USER root
18+
19+
CMD ["python", "-m", "stac_fastapi.elasticsearch.app"]

dockerfiles/Dockerfile.ci.os

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM python:3.12-slim
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update && \
6+
apt-get install -y --no-install-recommends \
7+
gcc \
8+
curl \
9+
&& apt-get clean && \
10+
rm -rf /var/lib/apt/lists/*
11+
12+
COPY . /app/
13+
14+
RUN pip3 install --no-cache-dir -e ./stac_fastapi/core && \
15+
pip3 install --no-cache-dir ./stac_fastapi/opensearch[server]
16+
17+
USER root
18+
19+
CMD ["python", "-m", "stac_fastapi.opensearch.app"]
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "3.2.0"
2+
__version__ = "3.2.1"

stac_fastapi/elasticsearch/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
desc = f.read()
77

88
install_requires = [
9-
"stac-fastapi.core==3.2.0",
9+
"stac-fastapi.core==3.2.1",
1010
"elasticsearch[async]==8.11.0",
1111
"elasticsearch-dsl==8.11.0",
1212
"uvicorn",
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "3.2.0"
2+
__version__ = "3.2.1"

stac_fastapi/opensearch/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
desc = f.read()
77

88
install_requires = [
9-
"stac-fastapi.core==3.2.0",
9+
"stac-fastapi.core==3.2.1",
1010
"opensearch-py==2.4.2",
1111
"opensearch-py[async]==2.4.2",
1212
"uvicorn",
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "3.2.0"
2+
__version__ = "3.2.1"

0 commit comments

Comments
 (0)