-
Notifications
You must be signed in to change notification settings - Fork 31
add build push docker image image in the publish ci #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
6c0eac5
b19aec9
b24192e
710b8f4
795fa87
bd5cddf
c97d6f0
7226fc1
0e70af2
feb24d2
e8d6fc4
15b0d65
4826f19
3e67674
34f36a1
a2ee00b
12af96a
808ee37
f4ab110
10eba9b
c033dfb
562f7b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,38 +33,98 @@ | |
| - We are always welcoming contributions. For the development notes: [Contributing](CONTRIBUTING.md) | ||
|
|
||
|
|
||
| ### To install from PyPI: | ||
| ### Installing STAC-FastAPI from PyPI | ||
|
|
||
| ```shell | ||
| To install STAC-FastAPI with Elasticsearch or OpenSearch backend support, run the following command: | ||
|
|
||
| For Elasticsearch: | ||
| ```bash | ||
| pip install stac_fastapi.elasticsearch | ||
| ``` | ||
| or | ||
| ``` | ||
|
|
||
| For OpenSearch: | ||
| ```bash | ||
| pip install stac_fastapi.opensearch | ||
| ``` | ||
|
|
||
| ## Build Elasticsearch API backend | ||
| ## Running STAC-FastAPI Elasticsearch or OpenSearch API on `localhost:8080` | ||
|
|
||
| ```shell | ||
| docker-compose up elasticsearch | ||
| docker-compose build app-elasticsearch | ||
| Before starting, [Docker](https://docs.docker.com/get-started/) or [Podman](https://podman.io/docs) has to be installed and running on your machine. | ||
|
|
||
| ### Step 1: Configure the `.env` File | ||
|
|
||
| You need to provide a `.env` file to configure the environment variables. Here's a list of variables you can configure: | ||
|
|
||
| - `STAC_FASTAPI_TITLE`: Title of the API shown in the documentation (default: `stac-fastapi-elasticsearch` or `stac-fastapi-opensearch`) | ||
|
||
| - `STAC_FASTAPI_DESCRIPTION`: Description of the API in the documentation | ||
| - `STAC_FASTAPI_VERSION`: API version (default: `2.1`) | ||
| - `APP_HOST`: Host to bind the server (default: `0.0.0.0`) | ||
| - `APP_PORT`: Port to bind the server (default: `8080`) | ||
| - `RELOAD`: Enable auto-reload for development (default: `true`) | ||
| - `ENVIRONMENT`: Runtime environment (default: `local`) | ||
| - `WEB_CONCURRENCY`: Number of worker processes (default: `10`) | ||
| - `ES_HOST`: Elasticsearch or OpenSearch host (default: `localhost`) | ||
| - `ES_PORT`: Elasticsearch port (default: `9200` for Elasticsearch, `9202` for OpenSearch) | ||
| - `ES_USE_SSL`: Enable SSL for Elasticsearch (default: `false`) | ||
| - `ES_VERIFY_CERTS`: Verify SSL certificates (default: `false`) | ||
| - `BACKEND`: Backend type (`elasticsearch` or `opensearch`) | ||
| - `STAC_FASTAPI_RATE_LIMIT`: API rate limit per client (default: `200/minute`) | ||
|
|
||
| > [!NOTE] | ||
| > 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. | ||
| ### Step 2: Running the Backend with Elasticsearch | ||
|
|
||
| To run the backend with Elasticsearch, use the following command: | ||
|
|
||
| ```bash | ||
| docker run -d \ | ||
| --env-file .env \ | ||
| -p 9200:9200 \ | ||
| -p 8080:8080 \ | ||
| ghcr.io/stac-utils/stac-fastapi-es:latest | ||
| ``` | ||
| or | ||
| ```bash | ||
| podman run -d \ | ||
| --env-file .env \ | ||
| -p 9200:9200 \ | ||
| -p 8080:8080 \ | ||
| ghcr.io/stac-utils/stac-fastapi-es:latest | ||
| ``` | ||
|
|
||
| ## Running Elasticsearch API on localhost:8080 | ||
| ### Step 3: Running the Backend with OpenSearch | ||
|
|
||
| ```shell | ||
| docker-compose up app-elasticsearch | ||
| To run the backend with OpenSearch, use the following command: | ||
|
|
||
| ```bash | ||
| docker run -d \ | ||
| --env-file .env \ | ||
| -p 9202:9202 \ | ||
| -p 8080:8080 \ | ||
| ghcr.io/stac-utils/stac-fastapi-os:latest | ||
| ``` | ||
| or | ||
| ```bash | ||
| podman run -d \ | ||
| --env-file .env \ | ||
| -p 9202:9202 \ | ||
| -p 8080:8080 \ | ||
| ghcr.io/stac-utils/stac-fastapi-os:latest | ||
| ``` | ||
| ### Step 4: Verifying the Backend is Running | ||
|
|
||
| By default, docker-compose uses Elasticsearch 8.x and OpenSearch 2.11.1. | ||
| If you wish to use a different version, put the following in a | ||
| file named `.env` in the same directory you run docker-compose from: | ||
| To check if the container is running, use the following command depending on whether you're using Docker or Podman: | ||
|
|
||
| ```shell | ||
| ELASTICSEARCH_VERSION=7.17.1 | ||
| OPENSEARCH_VERSION=2.11.0 | ||
| ```bash | ||
| docker ps | ||
| ``` | ||
| 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. | ||
| or | ||
| ```bash | ||
| podman ps | ||
| ``` | ||
|
|
||
| ## Interacting with the API | ||
|
|
||
| To create a new Collection: | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| FROM debian:bookworm-slim AS base | ||
|
|
||
| ARG STAC_FASTAPI_TITLE | ||
|
||
| ARG STAC_FASTAPI_DESCRIPTION | ||
| ARG STAC_FASTAPI_VERSION | ||
| ARG APP_HOST | ||
| ARG APP_PORT | ||
| ARG RELOAD | ||
| ARG ENVIRONMENT | ||
| ARG WEB_CONCURRENCY | ||
| ARG ES_HOST | ||
| ARG ES_PORT | ||
| ARG ES_USE_SSL | ||
| ARG ES_VERIFY_CERTS | ||
| ARG BACKEND | ||
|
|
||
| ENV STAC_FASTAPI_TITLE=${STAC_FASTAPI_TITLE} | ||
| ENV STAC_FASTAPI_DESCRIPTION=${STAC_FASTAPI_DESCRIPTION} | ||
| ENV STAC_FASTAPI_VERSION=${STAC_FASTAPI_VERSION} | ||
| ENV APP_HOST=${APP_HOST} | ||
| ENV APP_PORT=${APP_PORT} | ||
| ENV RELOAD=${RELOAD} | ||
| ENV ENVIRONMENT=${ENVIRONMENT} | ||
| ENV WEB_CONCURRENCY=${WEB_CONCURRENCY} | ||
| ENV ES_HOST=${ES_HOST} | ||
| ENV ES_PORT=${ES_PORT} | ||
| ENV ES_USE_SSL=${ES_USE_SSL} | ||
| ENV ES_VERIFY_CERTS=${ES_VERIFY_CERTS} | ||
| ENV BACKEND=${BACKEND} | ||
|
|
||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| gcc \ | ||
| curl \ | ||
| python3 \ | ||
| python3-pip \ | ||
| python3-venv \ | ||
| && apt-get clean && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # set non-root user | ||
| RUN groupadd -g 1000 elasticsearch && \ | ||
| useradd -u 1000 -g elasticsearch -s /bin/bash -m elasticsearch | ||
|
|
||
| # elasticsearch binaries and libraries | ||
| COPY --from=docker.elastic.co/elasticsearch/elasticsearch:8.11.0 /usr/share/elasticsearch /usr/share/elasticsearch | ||
|
|
||
| # ser ownership | ||
| RUN chown -R elasticsearch:elasticsearch /usr/share/elasticsearch | ||
|
|
||
| WORKDIR /app | ||
| COPY . /app | ||
|
|
||
| # stac-fastapi-es installation | ||
| RUN pip3 install --no-cache-dir --break-system-packages -e ./stac_fastapi/core && \ | ||
| pip3 install --no-cache-dir --break-system-packages ./stac_fastapi/elasticsearch[server] | ||
|
|
||
| COPY elasticsearch/config/elasticsearch.yml /usr/share/elasticsearch/config/elasticsearch.yml | ||
|
|
||
| COPY dockerfiles/entrypoint-es.sh /entrypoint.sh | ||
| RUN chmod +x /entrypoint.sh | ||
|
|
||
|
|
||
| ENV ES_JAVA_OPTS="-Xms512m -Xmx1g" \ | ||
| PATH="/usr/share/elasticsearch/bin:${PATH}" | ||
|
|
||
|
|
||
| HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD \ | ||
| curl --silent --fail http://${ES_HOST}:${ES_PORT}/_cluster/health || exit 1 && \ | ||
| curl --silent --fail http://${APP_HOST}:${APP_PORT}/api.html || exit 1 | ||
|
|
||
| EXPOSE $APP_PORT $ES_PORT | ||
|
|
||
| USER elasticsearch | ||
| ENTRYPOINT ["/entrypoint.sh"] | ||
Uh oh!
There was an error while loading. Please reload this page.