|
33 | 33 | - We are always welcoming contributions. For the development notes: [Contributing](CONTRIBUTING.md) |
34 | 34 |
|
35 | 35 |
|
36 | | -### To install from PyPI: |
| 36 | +### Installing STAC-FastAPI from PyPI |
37 | 37 |
|
38 | | -```shell |
| 38 | +To install STAC-FastAPI with Elasticsearch or OpenSearch backend support, run the following command: |
| 39 | + |
| 40 | +For Elasticsearch: |
| 41 | +```bash |
39 | 42 | pip install stac_fastapi.elasticsearch |
40 | 43 | ``` |
41 | | -or |
42 | | -``` |
| 44 | + |
| 45 | +For OpenSearch: |
| 46 | +```bash |
43 | 47 | pip install stac_fastapi.opensearch |
44 | 48 | ``` |
45 | 49 |
|
46 | | -## Build Elasticsearch API backend |
| 50 | +## Running STAC-FastAPI Elasticsearch or OpenSearch API on `localhost:8080` |
47 | 51 |
|
48 | | -```shell |
49 | | -docker-compose up elasticsearch |
50 | | -docker-compose build app-elasticsearch |
| 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 | + |
| 54 | +### Step 1: Configure the `.env` File |
| 55 | + |
| 56 | +You need to provide a `.env` file to configure the environment variables. Here's a list of variables you can configure: |
| 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`) |
| 63 | +- `RELOAD`: Enable auto-reload for development (default: `true`) |
| 64 | +- `ENVIRONMENT`: Runtime environment (default: `local`) |
| 65 | +- `WEB_CONCURRENCY`: Number of worker processes (default: `10`) |
| 66 | +- `ES_HOST`: Elasticsearch or OpenSearch host (default: `localhost`) |
| 67 | +- `ES_PORT`: Elasticsearch port (default: `9200` for Elasticsearch, `9202` for OpenSearch) |
| 68 | +- `ES_USE_SSL`: Enable SSL for Elasticsearch (default: `false`) |
| 69 | +- `ES_VERIFY_CERTS`: Verify SSL certificates (default: `false`) |
| 70 | +- `BACKEND`: Backend type (`elasticsearch` or `opensearch`) |
| 71 | +- `STAC_FASTAPI_RATE_LIMIT`: API rate limit per client (default: `200/minute`) |
| 72 | + |
| 73 | +> [!NOTE] |
| 74 | +> 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. |
| 75 | +
|
| 76 | +### Step 2: Running the Backend with Elasticsearch |
| 77 | + |
| 78 | +To run the backend with Elasticsearch, use the following command: |
| 79 | + |
| 80 | +```bash |
| 81 | +docker run -d \ |
| 82 | + --env-file .env \ |
| 83 | + -p 9200:9200 \ |
| 84 | + -p 8080:8080 \ |
| 85 | + ghcr.io/stac-utils/stac-fastapi-es:latest |
| 86 | +``` |
| 87 | +or |
| 88 | +```bash |
| 89 | +podman run -d \ |
| 90 | + --env-file .env \ |
| 91 | + -p 9200:9200 \ |
| 92 | + -p 8080:8080 \ |
| 93 | + ghcr.io/stac-utils/stac-fastapi-es:latest |
51 | 94 | ``` |
52 | 95 |
|
53 | | -## Running Elasticsearch API on localhost:8080 |
| 96 | +### Step 3: Running the Backend with OpenSearch |
54 | 97 |
|
55 | | -```shell |
56 | | -docker-compose up app-elasticsearch |
| 98 | +To run the backend with OpenSearch, use the following command: |
| 99 | + |
| 100 | +```bash |
| 101 | +docker run -d \ |
| 102 | + --env-file .env \ |
| 103 | + -p 9202:9202 \ |
| 104 | + -p 8080:8080 \ |
| 105 | + ghcr.io/stac-utils/stac-fastapi-os:latest |
57 | 106 | ``` |
| 107 | +or |
| 108 | +```bash |
| 109 | +podman run -d \ |
| 110 | + --env-file .env \ |
| 111 | + -p 9202:9202 \ |
| 112 | + -p 8080:8080 \ |
| 113 | + ghcr.io/stac-utils/stac-fastapi-os:latest |
| 114 | +``` |
| 115 | +### Step 4: Verifying the Backend is Running |
58 | 116 |
|
59 | | -By default, docker-compose uses Elasticsearch 8.x and OpenSearch 2.11.1. |
60 | | -If you wish to use a different version, put the following in a |
61 | | -file named `.env` in the same directory you run docker-compose from: |
| 117 | +To check if the container is running, use the following command depending on whether you're using Docker or Podman: |
62 | 118 |
|
63 | | -```shell |
64 | | -ELASTICSEARCH_VERSION=7.17.1 |
65 | | -OPENSEARCH_VERSION=2.11.0 |
| 119 | +```bash |
| 120 | +docker ps |
66 | 121 | ``` |
67 | | -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. |
| 122 | +or |
| 123 | +```bash |
| 124 | +podman ps |
| 125 | +``` |
| 126 | + |
| 127 | +## Interacting with the API |
68 | 128 |
|
69 | 129 | To create a new Collection: |
70 | 130 |
|
|
0 commit comments