Skip to content

Add opensearch backend #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.pgdata
.pgdata
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ python -m stac_auth_proxy
uvicorn --factory stac_auth_proxy:create_app
```

### Docker compose

Run all of the services required to run the application locally including the the database, STAC API, and Mock OICD provider using Docker compose.

Spin up the application stack with the pgSTAC backend using [stac-fastapi-pgstac](https://github.com/stac-utils/stac-fastapi-pgstac):
```sh
UPSTREAM_URL=http://stac-pg:8001 docker compose --profile pg up
```

and with the OpenSearch backend using [stac-fastapi-elasticsearch-opensearch](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch):
```sh
UPSTREAM_URL=http://stac-os:8001 docker compose --profile os up
```


### Installation

For local development, we use [`uv`](https://docs.astral.sh/uv/) to manage project dependencies and environment.
Expand Down
69 changes: 57 additions & 12 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
stac:
stac-pg:
profiles: ["pg"]
image: ghcr.io/stac-utils/stac-fastapi-pgstac:5.0.2
environment:
APP_HOST: 0.0.0.0
Expand All @@ -9,8 +10,8 @@ services:
POSTGRES_USER: username
POSTGRES_PASS: password
POSTGRES_DBNAME: postgis
POSTGRES_HOST_READER: database
POSTGRES_HOST_WRITER: database
POSTGRES_HOST_READER: database-pg
POSTGRES_HOST_WRITER: database-pg
POSTGRES_PORT: 5432
WEB_CONCURRENCY: 10
VSI_CACHE: TRUE
Expand All @@ -22,10 +23,40 @@ services:
ports:
- "8001:8001"
depends_on:
- database
command: bash -c "./scripts/wait-for-it.sh database:5432 && python -m stac_fastapi.pgstac.app"
- database-pg
command: bash -c "./scripts/wait-for-it.sh database-pg:5432 && python -m stac_fastapi.pgstac.app"

database:
stac-os:
profiles: ["os"]
container_name: stac-fastapi-os
image: ghcr.io/stac-utils/stac-fastapi-os:v6.1.0
hostname: stac-os
environment:
STAC_FASTAPI_TITLEL: stac-fastapi-opensearch
STAC_FASTAPI_DESCRIPTION: A STAC FastAPI with an Opensearch backend
STAC_FASTAPI_VERSION: 6.0.0
STAC_FASTAPI_LANDING_PAGE_ID: stac-fastapi-opensearch
APP_HOST: 0.0.0.0
APP_PORT: 8001
RELOAD: true
ENVIRONMENT: local
WEB_CONCURRENCY: 10
ES_HOST: database-os
ES_PORT: 9200
ES_USE_SSL: false
ES_VERIFY_CERTS: false
BACKEND: opensearch
STAC_FASTAPI_RATE_LIMIT: 200/minute
ports:
- "8001:8001"
depends_on:
- database-os
command:
bash -c "./scripts/wait-for-it-es.sh database-os:9200 && python -m stac_fastapi.opensearch.app"

database-pg:
profiles: ["pg"]
container_name: database-pg
image: ghcr.io/stac-utils/pgstac:v0.9.5
environment:
POSTGRES_USER: username
Expand All @@ -40,13 +71,30 @@ services:
volumes:
- ./.pgdata:/var/lib/postgresql/data

database-os:
profiles: ["os"]
container_name: database-os
image: opensearchproject/opensearch:${OPENSEARCH_VERSION:-2.11.1}
hostname: database-os
environment:
cluster.name: stac-cluster
node.name: os01
http.port: 9200
http.cors.allow-headers: X-Requested-With,Content-Type,Content-Length,Accept,Authorization
discovery.type: single-node
plugins.security.disabled: true
OPENSEARCH_JAVA_OPTS: -Xms512m -Xmx512m
ports:
- "9200:9200"

proxy:
profiles: ["pg", "os"]
depends_on:
- stac
- oidc
build:
context: .
environment:
UPSTREAM_URL: ${UPSTREAM_URL:-http://stac:8001}
UPSTREAM_URL: ${UPSTREAM_URL:-http://stac-pg:8001}
OIDC_DISCOVERY_URL: ${OIDC_DISCOVERY_URL:-http://localhost:8888/.well-known/openid-configuration}
OIDC_DISCOVERY_INTERNAL_URL: ${OIDC_DISCOVERY_INTERNAL_URL:-http://oidc:8888/.well-known/openid-configuration}
env_file:
Expand All @@ -58,14 +106,11 @@ services:
- ./src:/app/src

oidc:
profiles: ["pg", "os"]
image: ghcr.io/alukach/mock-oidc-server:latest
environment:
ISSUER: http://localhost:8888
SCOPES: item:create,item:update,item:delete,collection:create,collection:update,collection:delete
PORT: 8888
ports:
- "8888:8888"

networks:
default:
name: eoapi-network