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
## Running STAC-FastAPI Elasticsearch or OpenSearch API
51
51
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.
52
+
### Prerequisites
53
53
54
-
### Step 1: Configure the `.env` File
54
+
-[**Docker**](https://docs.docker.com/get-started/) or [**Podman**](https://podman.io/docs) installed and running on your machine.
55
55
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.
56
+
### Step 1: Set Up the Environment Variables
57
+
Create a `.env` file to configure your setup. Depending on your preference, you can either connect to an external Elasticsearch/OpenSearch instance or run one locally within the same container.
57
58
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:
59
+
#### Option A: Connect to an External Elasticsearch/OpenSearch Instance
59
60
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.
61
+
1. Open your `.env` file.
62
+
2. Set the following variables to point to your external Elasticsearch or OpenSearch server:
63
+
64
+
```env
65
+
ES_HOST=your_external_host
66
+
ES_PORT=your_external_port
67
+
ES_USE_SSL=false # Set to 'true' if your server uses SSL
68
+
ES_VERIFY_CERTS=false # Set to 'true' to verify SSL certificates
69
+
```
70
+
71
+
#### Option B: Run Elasticsearch/OpenSearch Locally
72
+
73
+
1. Open your `.env` file.
74
+
2. Enable one of the following to run the service locally within the container:
75
+
76
+
```env
77
+
# For Elasticsearch
78
+
RUN_LOCAL_ES=1
79
+
80
+
# For OpenSearch
81
+
RUN_LOCAL_OS=1
82
+
```
62
83
63
84
> [!IMPORTANT]
64
85
> The variables `RUN_LOCAL_ES` and `RUN_LOCAL_OS` correspond to **different Docker images**:
65
86
> - Use `RUN_LOCAL_ES` with the `ghcr.io/stac-utils/stac-fastapi-es` image.
66
87
> - Use `RUN_LOCAL_OS` with the `ghcr.io/stac-utils/stac-fastapi-os` image.
67
88
89
+
### Step 2: Run the STAC-FastAPI Container
90
+
91
+
#### Option A: Using an External Instance
92
+
93
+
-**For Elasticsearch:**
94
+
95
+
```bash
96
+
docker run -d \
97
+
-p 8080:8080 \
98
+
--env-file .env \
99
+
ghcr.io/stac-utils/stac-fastapi-es:latest
100
+
```
101
+
102
+
-**For OpenSearch:**
103
+
104
+
```bash
105
+
docker run -d \
106
+
-p 8080:8080 \
107
+
--env-file .env \
108
+
ghcr.io/stac-utils/stac-fastapi-os:latest
109
+
```
110
+
111
+
#### Option B: Running Locally in the Same Container as APP
112
+
113
+
-**For Elasticsearch:**
114
+
115
+
```bash
116
+
docker run -d \
117
+
-p 8080:8080 \
118
+
-p 9200:9200 \
119
+
--env-file .env \
120
+
ghcr.io/stac-utils/stac-fastapi-es:latest
121
+
```
122
+
123
+
-**For OpenSearch:**
124
+
125
+
```bash
126
+
docker run -d \
127
+
-p 8080:8080 \
128
+
-p 9202:9202 \
129
+
--env-file .env \
130
+
ghcr.io/stac-utils/stac-fastapi-os:latest
131
+
```
132
+
133
+
> [!TIP]
134
+
> 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.
135
+
136
+
### Step 3: Verify the Service is Running
68
137
69
-
Here are the key variables to configure:
138
+
Run the following command to check if your container is up and running:
139
+
140
+
```bash
141
+
docker ps # "podman ps" if you are running via podman
142
+
```
143
+
144
+
You should see the STAC-FastAPI container listed.
145
+
146
+
## Accessing the API
147
+
148
+
Once the container is up and running, access the API at:
149
+
150
+
```
151
+
http://localhost:8080
152
+
```
153
+
154
+
## Additional Configuration (Optional)
155
+
156
+
You can customize additional settings in your `.env` file:
@@ -91,71 +179,6 @@ Here are the key variables to configure:
91
179
> 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
180
93
181
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
-
```
143
-
144
-
> [!TIP]
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.
146
-
147
-
### Step 3: Verifying the STAC-FastAPI ELasticSearch or OpenSearch is Running
148
-
149
-
To check if the container is running, use the following command depending on whether you're using Docker or Podman:
0 commit comments