Skip to content

Commit d779321

Browse files
docs(docker): Add OpenSearch backend stack to docker-compose (#71)
This PR adds the OpenSearch backend as an option in the docker-compose file --------- Co-authored-by: Anthony Lukach <[email protected]>
1 parent bfb9ca8 commit d779321

File tree

3 files changed

+90
-18
lines changed

3 files changed

+90
-18
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.pgdata

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
STAC Auth Proxy is a proxy API that mediates between the client and your internally accessible STAC API to provide flexible authentication, authorization, and content-filtering mechanisms.
99

1010
> [!IMPORTANT]
11+
>
1112
> **We would :heart: to hear from you!**
1213
> Please [join the discussion](https://github.com/developmentseed/eoAPI/discussions/209) and let us know how you're using eoAPI! This helps us improve the project for you and others.
1314
> If you prefer to remain anonymous, you can email us at [email protected], and we'll be happy to post a summary on your behalf.
@@ -25,7 +26,9 @@ STAC Auth Proxy is a proxy API that mediates between the client and your interna
2526

2627
### Running
2728

28-
The simplest way to run the project is by invoking the application via Docker:
29+
#### Docker
30+
31+
The simplest way to run the project is via Docker:
2932

3033
```sh
3134
docker run \
@@ -36,16 +39,42 @@ docker run \
3639
ghcr.io/developmentseed/stac-auth-proxy:latest
3740
```
3841

39-
Alternatively, the module can be invoked directly or the application's factory can be passed to Uvicorn:
42+
#### Python
43+
44+
The installed Python module can be invoked directly:
4045

4146
```sh
4247
python -m stac_auth_proxy
4348
```
4449

50+
#### Uvicorn
51+
52+
The application's factory can be passed to Uvicorn:
53+
4554
```sh
4655
uvicorn --factory stac_auth_proxy:create_app
4756
```
4857

58+
#### Docker Compose
59+
60+
The codebase ships with a `docker-compose.yaml` file, allowing the proxy to be run locally alongside various supporting services: the database, the STAC API, and a Mock OIDC provider.
61+
62+
##### pgSTAC Backend
63+
64+
Run the application stack with a pgSTAC backend using [stac-fastapi-pgstac](https://github.com/stac-utils/stac-fastapi-pgstac):
65+
66+
```sh
67+
docker compose up
68+
```
69+
70+
##### OpenSearch Backend
71+
72+
Run the application stack with an OpenSearch backend using [stac-fastapi-elasticsearch-opensearch](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch):
73+
74+
```sh
75+
docker compose --profile os up
76+
```
77+
4978
### Installation
5079

5180
The application can be installed as a standard Python module:
@@ -65,6 +94,7 @@ uv sync
6594
The application is configurable via environment variables.
6695

6796
#### Core
97+
6898
- **`UPSTREAM_URL`**, STAC API URL
6999
- **Type:** HTTP(S) URL
70100
- **Required:** Yes
@@ -96,6 +126,7 @@ The application is configurable via environment variables.
96126
- **Note:** This is independent of the upstream API's path. The proxy will handle removing this prefix from incoming requests and adding it to outgoing links.
97127

98128
#### Authentication
129+
99130
- **`OIDC_DISCOVERY_URL`**, OpenID Connect discovery document URL
100131
- **Type:** HTTP(S) URL
101132
- **Required:** Yes
@@ -137,6 +168,7 @@ The application is configurable via environment variables.
137168
- **Example:** `false`, `1`, `True`
138169

139170
#### OpenAPI / Swagger UI
171+
140172
- **`OPENAPI_SPEC_ENDPOINT`**, path of OpenAPI specification, used for augmenting spec response with auth configuration
141173
- **Type:** string or null
142174
- **Required:** No, defaults to `null` (disabled)
@@ -159,6 +191,7 @@ The application is configurable via environment variables.
159191
- **Example:** `{"clientId": "stac-auth-proxy", "usePkceWithAuthorizationCodeGrant": true}`
160192

161193
#### Filtering
194+
162195
- **`ITEMS_FILTER_CLS`**, CQL2 expression generator for item-level filtering
163196
- **Type:** JSON object with class configuration
164197
- **Required:** No, defaults to `null` (disabled)

docker-compose.yaml

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,57 @@
11
services:
2-
stac:
2+
stac-pg:
3+
profiles: [""] # default profile
34
image: ghcr.io/stac-utils/stac-fastapi-pgstac:5.0.2
45
environment:
56
APP_HOST: 0.0.0.0
67
APP_PORT: 8001
78
RELOAD: true
8-
ENVIRONMENT: local
99
POSTGRES_USER: username
1010
POSTGRES_PASS: password
1111
POSTGRES_DBNAME: postgis
12-
POSTGRES_HOST_READER: database
13-
POSTGRES_HOST_WRITER: database
12+
POSTGRES_HOST_READER: database-pg
13+
POSTGRES_HOST_WRITER: database-pg
1414
POSTGRES_PORT: 5432
15-
WEB_CONCURRENCY: 10
16-
VSI_CACHE: TRUE
17-
GDAL_HTTP_MERGE_CONSECUTIVE_RANGES: YES
18-
GDAL_DISABLE_READDIR_ON_OPEN: EMPTY_DIR
1915
DB_MIN_CONN_SIZE: 1
2016
DB_MAX_CONN_SIZE: 1
2117
USE_API_HYDRATE: ${USE_API_HYDRATE:-false}
18+
hostname: stac
19+
ports:
20+
- "8001:8001"
21+
depends_on:
22+
- database-pg
23+
command: bash -c "./scripts/wait-for-it.sh database-pg:5432 && python -m stac_fastapi.pgstac.app"
24+
25+
stac-os:
26+
profiles: ["os"]
27+
container_name: stac-fastapi-os
28+
image: ghcr.io/stac-utils/stac-fastapi-os:v6.1.0
29+
environment:
30+
STAC_FASTAPI_TITLE: stac-fastapi-opensearch
31+
STAC_FASTAPI_DESCRIPTION: A STAC FastAPI with an Opensearch backend
32+
STAC_FASTAPI_VERSION: 6.0.0
33+
STAC_FASTAPI_LANDING_PAGE_ID: stac-fastapi-opensearch
34+
APP_HOST: 0.0.0.0
35+
APP_PORT: 8001
36+
RELOAD: true
37+
ENVIRONMENT: local
38+
ES_HOST: database-os
39+
ES_PORT: 9200
40+
ES_USE_SSL: false
41+
ES_VERIFY_CERTS: false
42+
BACKEND: opensearch
43+
STAC_FASTAPI_RATE_LIMIT: 200/minute
44+
hostname: stac
2245
ports:
2346
- "8001:8001"
2447
depends_on:
25-
- database
26-
command: bash -c "./scripts/wait-for-it.sh database:5432 && python -m stac_fastapi.pgstac.app"
48+
- database-os
49+
command: |
50+
bash -c "./scripts/wait-for-it-es.sh database-os:9200 && python -m stac_fastapi.opensearch.app"
2751
28-
database:
52+
database-pg:
53+
profiles: [""] # default profile
54+
container_name: database-pg
2955
image: ghcr.io/stac-utils/pgstac:v0.9.5
3056
environment:
3157
POSTGRES_USER: username
@@ -40,9 +66,25 @@ services:
4066
volumes:
4167
- ./.pgdata:/var/lib/postgresql/data
4268

69+
database-os:
70+
profiles: ["os"]
71+
container_name: database-os
72+
image: opensearchproject/opensearch:${OPENSEARCH_VERSION:-2.11.1}
73+
hostname: database-os
74+
environment:
75+
cluster.name: stac-cluster
76+
node.name: os01
77+
http.port: 9200
78+
http.cors.allow-headers: X-Requested-With,Content-Type,Content-Length,Accept,Authorization
79+
discovery.type: single-node
80+
plugins.security.disabled: true
81+
OPENSEARCH_JAVA_OPTS: -Xms512m -Xmx512m
82+
ports:
83+
- "9200:9200"
84+
4385
proxy:
4486
depends_on:
45-
- stac
87+
- oidc
4688
build:
4789
context: .
4890
environment:
@@ -65,7 +107,3 @@ services:
65107
PORT: 8888
66108
ports:
67109
- "8888:8888"
68-
69-
networks:
70-
default:
71-
name: eoapi-network

0 commit comments

Comments
 (0)