|
32 | 32 | - For changes, see the [Changelog](CHANGELOG.md) |
33 | 33 | - We are always welcoming contributions. For the development notes: [Contributing](CONTRIBUTING.md) |
34 | 34 |
|
| 35 | +## Installation and Running: |
35 | 36 |
|
36 | | -### Installing STAC-FastAPI from PyPI |
| 37 | +### **Method 1: Install via PyPI and Run with Docker Compose or Podman Compose** |
37 | 38 |
|
38 | | -To install STAC-FastAPI with Elasticsearch or OpenSearch backend support, run the following command: |
| 39 | +#### **Prerequisites** |
| 40 | + |
| 41 | +- [**Docker Compose**](https://docs.docker.com/compose/install/) or [**Podman Compose**](https://podman-desktop.io/docs/compose) installed and running on your machine. In all the follwoing steps instead of `docker-compose` you can use `podman-compose` as well. |
| 42 | + |
| 43 | +#### **Step 1: Install STAC-FastAPI** |
| 44 | + |
| 45 | +To install STAC-FastAPI with Elasticsearch or OpenSearch backend support, execute the following commands: |
| 46 | + |
| 47 | +- **For Elasticsearch backend:** |
| 48 | + |
| 49 | + ```bash |
| 50 | + pip install stac_fastapi.elasticsearch |
| 51 | + ``` |
| 52 | + |
| 53 | +- **For OpenSearch backend:** |
| 54 | + |
| 55 | + ```bash |
| 56 | + pip install stac_fastapi.opensearch |
| 57 | + ``` |
| 58 | + |
| 59 | +#### **Step 2: Build the Elasticsearch API Backend** |
| 60 | + |
| 61 | +Start the Elasticsearch service and build the STAC-FastAPI application image: |
39 | 62 |
|
40 | | -For Elasticsearch: |
41 | 63 | ```bash |
42 | | -pip install stac_fastapi.elasticsearch |
| 64 | +docker-compose up -d elasticsearch |
| 65 | +docker-compose build app-elasticsearch |
43 | 66 | ``` |
44 | 67 |
|
45 | | -For OpenSearch: |
| 68 | +#### **Step 3: Run the Elasticsearch API on `localhost:8080`** |
| 69 | + |
| 70 | +Launch the STAC-FastAPI application connected to Elasticsearch: |
| 71 | + |
46 | 72 | ```bash |
47 | | -pip install stac_fastapi.opensearch |
| 73 | +docker-compose up -d app-elasticsearch |
48 | 74 | ``` |
49 | 75 |
|
50 | | -## Running STAC-FastAPI Elasticsearch or OpenSearch API |
| 76 | +By default, Docker Compose uses Elasticsearch 8.x and OpenSearch 2.11.1. If you prefer to use different versions, create a file named `.env` in the same directory where you run Docker Compose and include the following lines: |
| 77 | + |
| 78 | +```env |
| 79 | +ELASTICSEARCH_VERSION=7.17.1 |
| 80 | +OPENSEARCH_VERSION=2.11.0 |
| 81 | +``` |
51 | 82 |
|
52 | | -### Prerequisites |
| 83 | +Most recent Elasticsearch 7.x versions should also be compatible. For detailed compatibility information, please refer to the [opensearch-py documentation](https://github.com/opensearch-project/opensearch-py/blob/main/COMPATIBILITY.md). |
53 | 84 |
|
54 | | -- [**Docker**](https://docs.docker.com/get-started/) or [**Podman**](https://podman.io/docs) installed and running on your machine. |
| 85 | +### **Method 2: Install and run only with Docker or podman** |
55 | 86 |
|
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. |
| 87 | +#### Prerequisites |
58 | 88 |
|
59 | | -#### Option A: Connect to an External Elasticsearch/OpenSearch Instance |
| 89 | +- [**Docker**](https://docs.docker.com/get-started/) or [**Podman**](https://podman.io/docs) installed and running on your machine. In all the follwoing steps instead of `docker` you can use `podman` as well. |
60 | 90 |
|
61 | | -1. Open your `.env` file. |
62 | | -2. Set the following variables to point to your external Elasticsearch or OpenSearch server: |
| 91 | +#### **Step 1: Create a `.env` File** |
63 | 92 |
|
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 | | - ``` |
| 93 | +Configure your environment variables in a `.env` file. You can choose to connect to an external Elasticsearch/OpenSearch instance or run one locally within the container. |
70 | 94 |
|
71 | | -#### Option B: Run Elasticsearch/OpenSearch Locally |
| 95 | +- **Option A: Connect to an External Instance** |
72 | 96 |
|
73 | | -1. Open your `.env` file. |
74 | | -2. Enable one of the following to run the service locally within the container: |
| 97 | + ```env |
| 98 | + ES_HOST=your_external_host |
| 99 | + ES_PORT=your_external_port |
| 100 | + ES_USE_SSL=false # Set to 'true' if SSL is used |
| 101 | + ES_VERIFY_CERTS=false # Set to 'true' to verify SSL certificates |
| 102 | + ``` |
75 | 103 |
|
76 | | - ```env |
77 | | - # For Elasticsearch |
78 | | - RUN_LOCAL_ES=1 |
| 104 | +- **Option B: Running Locally Within the Container** |
79 | 105 |
|
80 | | - # For OpenSearch |
81 | | - RUN_LOCAL_OS=1 |
82 | | - ``` |
| 106 | + - **For Elasticsearch:** |
| 107 | + |
| 108 | + ```env |
| 109 | + RUN_LOCAL_ES=1 |
| 110 | + ``` |
| 111 | +
|
| 112 | + - **For OpenSearch:** |
| 113 | +
|
| 114 | + ```env |
| 115 | + RUN_LOCAL_OS=1 |
| 116 | + ``` |
83 | 117 |
|
84 | 118 | > [!IMPORTANT] |
85 | 119 | > The variables `RUN_LOCAL_ES` and `RUN_LOCAL_OS` correspond to **different Docker images**: |
86 | 120 | > - Use `RUN_LOCAL_ES` with the `ghcr.io/stac-utils/stac-fastapi-es` image. |
87 | 121 | > - Use `RUN_LOCAL_OS` with the `ghcr.io/stac-utils/stac-fastapi-os` image. |
88 | 122 |
|
89 | | -### Step 2: Run the STAC-FastAPI Container |
| 123 | +#### **Step 2: Run the Docker Container** |
90 | 124 |
|
91 | | -#### Option A: Using an External Instance |
| 125 | +- **For Elasticsearch Backend:** |
92 | 126 |
|
93 | | -- **For Elasticsearch:** |
| 127 | + - **Connecting to External Instance:** |
94 | 128 |
|
95 | | - ```bash |
96 | | - docker run -d \ |
97 | | - -p 8080:8080 \ |
98 | | - --env-file .env \ |
99 | | - ghcr.io/stac-utils/stac-fastapi-es:latest |
100 | | - ``` |
| 129 | + ```shell |
| 130 | + docker run -d -p 8080:8080 --env-file .env ghcr.io/stac-utils/stac-fastapi-es:latest |
| 131 | + ``` |
101 | 132 |
|
102 | | -- **For OpenSearch:** |
| 133 | + - **Running Locally:** |
103 | 134 |
|
104 | | - ```bash |
105 | | - docker run -d \ |
106 | | - -p 8080:8080 \ |
107 | | - --env-file .env \ |
108 | | - ghcr.io/stac-utils/stac-fastapi-os:latest |
109 | | - ``` |
| 135 | + ```shell |
| 136 | + docker run -d -p 8080:8080 -p 9200:9200 --env-file .env ghcr.io/stac-utils/stac-fastapi-es:latest |
| 137 | + ``` |
110 | 138 |
|
111 | | -#### Option B: Running Locally in the Same Container as APP |
| 139 | +- **For OpenSearch Backend:** |
112 | 140 |
|
113 | | -- **For Elasticsearch:** |
| 141 | + - **Connecting to External Instance:** |
114 | 142 |
|
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 | | - ``` |
| 143 | + ```shell |
| 144 | + docker run -d -p 8080:8080 --env-file .env ghcr.io/stac-utils/stac-fastapi-os:latest |
| 145 | + ``` |
122 | 146 |
|
123 | | -- **For OpenSearch:** |
| 147 | + - **Running Locally:** |
124 | 148 |
|
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 | | - ``` |
| 149 | + ```shell |
| 150 | + docker run -d -p 8080:8080 -p 9202:9202 --env-file .env ghcr.io/stac-utils/stac-fastapi-os:latest |
| 151 | + ``` |
132 | 152 |
|
133 | 153 | > [!TIP] |
134 | 154 | > 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 | 155 |
|
136 | | -### Step 3: Verify the Service is Running |
137 | 156 |
|
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 | | -``` |
| 157 | +#### **Step 3: Verify and Access** |
143 | 158 |
|
144 | | -You should see the STAC-FastAPI container listed. |
| 159 | +- **Check if the container is running:** |
145 | 160 |
|
146 | | -## Accessing the API |
| 161 | + ```shell |
| 162 | + docker ps # "podman ps" if you are running via podman |
| 163 | + ``` |
147 | 164 |
|
148 | | -Once the container is up and running, access the API at: |
| 165 | +- **Access the API:** |
149 | 166 |
|
150 | | -``` |
151 | | -http://localhost:8080 |
152 | | -``` |
| 167 | + Visit `http://localhost:8080` in your browser or use it as the base URL for API requests. |
153 | 168 |
|
154 | | -## Additional Configuration (Optional) |
| 169 | +##### **Configuration reference keys:** |
155 | 170 |
|
156 | 171 | You can customize additional settings in your `.env` file: |
157 | | -### Key variables to configure: |
| 172 | +###### Key variables to configure: |
158 | 173 |
|
159 | 174 | | Variable | Description | Default | Required | |
160 | 175 | |------------------------------|--------------------------------------------------------------------------------------|--------------------------|---------------------------------------------------------------------------------------------| |
|
0 commit comments