You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+82-49Lines changed: 82 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,71 +47,104 @@ For OpenSearch:
47
47
pip install stac_fastapi.opensearch
48
48
```
49
49
50
-
## Running STAC-FastAPI Elasticsearch or OpenSearch API on `localhost:8080`
50
+
## Running STAC-FastAPI Elasticsearch or OpenSearch API
51
51
52
52
Before starting, [Docker](https://docs.docker.com/get-started/) or [Podman](https://podman.io/docs) has to be installed and running on your machine.
53
53
54
-
### Step 1: Configure the `.env` File (Optional)
54
+
### Step 1: Configure the `.env` File
55
55
56
-
If you need to modify the default configuration, provide a `.env` file with your environment variables. Here's a list of configurable variables. If you're comfortable with the defaults, you can run the Docker container without any environment configuration.
56
+
The `.env` file lets you customize the runtime configuration. If you plan to connect to an external Elasticsearch or OpenSearch instance, set the `ES_HOST` and `ES_PORT` variables to point to your external server.
57
57
58
-
-`STAC_FASTAPI_TITLE`: Title of the API shown in the documentation (default: `stac-fastapi-elasticsearch` or `stac-fastapi-opensearch`)
59
-
-`STAC_FASTAPI_DESCRIPTION`: Description of the API in the documentation
60
-
-`STAC_FASTAPI_VERSION`: API version (default: `2.1`)
61
-
-`APP_HOST`: Host to bind the server (default: `0.0.0.0`)
62
-
-`APP_PORT`: Port to bind the server (default: `8080`)
-`STAC_FASTAPI_RATE_LIMIT`: API rate limit per client (default: `200/minute`)
58
+
Alternatively, if you want to run Elasticsearch or OpenSearch **within the same container** as the STAC-FastAPI, enable the respective environment variable in the `.env` file:
71
59
72
-
> [!NOTE]
73
-
> The variables `ES_HOST`, `ES_PORT`, `ES_USE_SSL`, and `ES_VERIFY_CERTS` apply to both Elasticsearch and OpenSearch, so there is no need to rename the key names to `OS_` even if you're using OpenSearch.
60
+
-**`RUN_LOCAL_ES`**: Set to `1` to run Elasticsearch locally within the container (default: `0`). Use this with the `stac-fastapi-es` image.
61
+
-**`RUN_LOCAL_OS`**: Set to `1`to run OpenSearch locally within the container (default: `0`). Use this with the `stac-fastapi-os` image.
74
62
75
-
### Step 2.1: Running the Backend with Elasticsearch
63
+
> [!IMPORTANT]
64
+
> The variables `RUN_LOCAL_ES` and `RUN_LOCAL_OS` correspond to **different Docker images**:
65
+
> - Use `RUN_LOCAL_ES` with the `ghcr.io/stac-utils/stac-fastapi-es` image.
66
+
> - Use `RUN_LOCAL_OS` with the `ghcr.io/stac-utils/stac-fastapi-os` image.
76
67
77
-
To run the backend with Elasticsearch, use the following command:
|`WEB_CONCURRENCY`| Number of worker processes. |`10`| Optional |
86
+
|`RELOAD`| Enable auto-reload for development. |`true`| Optional |
87
+
|`STAC_FASTAPI_RATE_LIMIT`| API rate limit per client. |`200/minute`| Optional |
94
88
95
-
To run the backend with OpenSearch, use the following command:
96
89
97
-
```bash
98
-
docker run -d \
99
-
-p 9202:9202 \
100
-
-p 8080:8080 \
101
-
ghcr.io/stac-utils/stac-fastapi-os:latest
102
-
```
103
-
or
104
-
```bash
105
-
podman run -d \
106
-
-p 9202:9202 \
107
-
-p 8080:8080 \
108
-
ghcr.io/stac-utils/stac-fastapi-os:latest
109
-
```
90
+
> [!NOTE]
91
+
> The variables `ES_HOST`, `ES_PORT`, `ES_USE_SSL`, and `ES_VERIFY_CERTS` apply to both Elasticsearch and OpenSearch, so there is no need to rename the key names to `OS_` even if you're using OpenSearch.
92
+
93
+
94
+
### Step 2: Running the Backend
95
+
96
+
Depending on your setup, follow one of the options below:
97
+
98
+
#### **Option A: Connect to External Elasticsearch/OpenSearch**
99
+
100
+
1. Update the `.env` file to include the `ES_HOST` and `ES_PORT` values of your external ES/OS instance. (Based on the SSL certification you might need to consider changing `ES_USE_SSL` and `ES_VERIFY_CERTS`)
101
+
2. Run the container with the appropriate image:
102
+
- For Elasticsearch:
103
+
```bash
104
+
docker run -d \
105
+
-p 8080:8080 \
106
+
--env-file .env \
107
+
ghcr.io/stac-utils/stac-fastapi-es:latest
108
+
```
109
+
- For OpenSearch:
110
+
```bash
111
+
docker run -d \
112
+
-p 8080:8080 \
113
+
--env-file .env \
114
+
ghcr.io/stac-utils/stac-fastapi-os:latest
115
+
```
116
+
117
+
#### **Option B: Run Elasticsearch/OpenSearch Locally in the Same Container**
118
+
119
+
If you'd like to run Elasticsearch or OpenSearch in the same container as the API:
120
+
121
+
1. In the `.env` file, enable the variable corresponding to your backend choice:
122
+
- Set `RUN_LOCAL_ES=1` to use Elasticsearch.
123
+
- Set `RUN_LOCAL_OS=1` to use OpenSearch.
124
+
125
+
2. Start the container using the appropriate image:
126
+
127
+
- For **Elasticsearch**:
128
+
```bash
129
+
docker run -d \
130
+
-p 9200:9200 \
131
+
-p 8080:8080 \
132
+
-e RUN_LOCAL_ES=1 \
133
+
ghcr.io/stac-utils/stac-fastapi-es:latest
134
+
```
135
+
- For **OpenSearch**:
136
+
```bash
137
+
docker run -d \
138
+
-p 9202:9202 \
139
+
-p 8080:8080 \
140
+
-e RUN_LOCAL_OS=1 \
141
+
ghcr.io/stac-utils/stac-fastapi-os:latest
142
+
```
110
143
111
144
> [!TIP]
112
145
> If you need to mount a volume, use the [`-v`](https://docs.docker.com/engine/storage/volumes/#choose-the--v-or---mount-flag) flag. To specify an environment file, use the [`--env-file`](https://docs.docker.com/reference/cli/docker/container/run/#env) flag.
113
146
114
-
### Step 3: Verifying the Backend is Running
147
+
### Step 3: Verifying the STAC-FastAPI ELasticSearch or OpenSearch is Running
115
148
116
149
To check if the container is running, use the following command depending on whether you're using Docker or Podman:
0 commit comments