Skip to content

Commit

Permalink
added default values and removed the unnecessary env vars from docker…
Browse files Browse the repository at this point in the history
… files since they already got defualt vals
  • Loading branch information
mo-dkrz committed Nov 16, 2024
1 parent 710b8f4 commit 795fa87
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 77 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ jobs:
- name: Test Elasticsearch image
run: |
docker run -d --name stac-es \
-e APP_HOST=0.0.0.0 \
-e APP_PORT=8080 \
-e ES_HOST=localhost \
-e ES_PORT=9200 \
stac-fastapi-es:test
timeout=120
Expand Down Expand Up @@ -169,10 +165,6 @@ jobs:
- name: Test OpenSearch image
run: |
docker run -d --name stac-os \
-e APP_HOST=0.0.0.0 \
-e APP_PORT=8080 \
-e OS_HOST=localhost \
-e OS_PORT=9200 \
stac-fastapi-os:test
timeout=120
Expand Down
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,68 +51,67 @@ pip install stac_fastapi.opensearch

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
### Step 1: Configure the `.env` File (Optional)

You need to provide a `.env` file to configure the environment variables. Here's a list of variables you can configure:
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.

- `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`)
- `WEB_CONCURRENCY`: Number of worker processes if more workers are needed (default: `10`)
- `RELOAD`: Enable auto-reload for development (default: `true`)
- `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.
> 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
### Step 2.1: 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
```

### Step 3: Running the Backend with OpenSearch
### Step 2.2: Running the Backend with OpenSearch

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

> [!TIP]
> 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.
### Step 3: Verifying the Backend is Running

To check if the container is running, use the following command depending on whether you're using Docker or Podman:

Expand Down
32 changes: 5 additions & 27 deletions dockerfiles/Dockerfile.ci.es
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
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}
ENV ENVIRONMENT="local"
ENV WEB_CONCURRENCY=10
ENV ES_USE_SSL=false
ENV ES_VERIFY_CERTS=false
ENV STAC_FASTAPI_RATE_LIMIT="200/minute"

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand Down
34 changes: 5 additions & 29 deletions dockerfiles/Dockerfile.ci.os
Original file line number Diff line number Diff line change
@@ -1,34 +1,10 @@
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
ARG STAC_FASTAPI_RATE_LIMIT

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}
ENV STAC_FASTAPI_RATE_LIMIT=${STAC_FASTAPI_RATE_LIMIT}
ENV ENVIRONMENT="local"
ENV WEB_CONCURRENCY=10
ENV ES_USE_SSL=false
ENV ES_VERIFY_CERTS=false
ENV STAC_FASTAPI_RATE_LIMIT="200/minute"

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand Down

0 comments on commit 795fa87

Please sign in to comment.