Skip to content
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

update runtimes and dockerfiles #16

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'

- name: Run pre-commit
run: |
Expand All @@ -36,11 +36,11 @@ jobs:
run: docker compose up -d

- name: install lib postgres
uses: nyurik/action-setup-postgis@v1
uses: nyurik/action-setup-postgis@v2

- name: Install python dependencies
run: |
python -m pip install pytest httpx pypgstac==0.8.5 psycopg[pool]
python -m pip install pytest httpx pypgstac==0.9.2 psycopg[pool]

- name: Ingest Stac Items/Collection
run: |
Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/tests/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ def test_mosaic_api():

searchid = resp.json()["id"]

resp = httpx.get(f"{raster_endpoint}/searches/{searchid}/-85.6358,36.1624/assets")
resp = httpx.get(
f"{raster_endpoint}/searches/{searchid}/point/-85.6358,36.1624/assets"
)
assert resp.status_code == 200
assert len(resp.json()) == 1
assert list(resp.json()[0]) == ["id", "bbox", "assets", "collection"]
assert resp.json()[0]["id"] == "20200307aC0853900w361030"

resp = httpx.get(
f"{raster_endpoint}/searches/{searchid}/tiles/15/8589/12849/assets"
f"{raster_endpoint}/searches/{searchid}/tiles/WebMercatorQuad/15/8589/12849/assets"
)
assert resp.status_code == 200
assert len(resp.json()) == 1
Expand All @@ -40,7 +42,7 @@ def test_mosaic_api():

z, x, y = 15, 8589, 12849
resp = httpx.get(
f"{raster_endpoint}/searches/{searchid}/tiles/{z}/{x}/{y}",
f"{raster_endpoint}/searches/{searchid}/tiles/WebMercatorQuad/{z}/{x}/{y}",
params={"assets": "cog"},
headers={"Accept-Encoding": "br, gzip"},
timeout=10.0,
Expand All @@ -53,15 +55,15 @@ def test_mosaic_api():
def test_mosaic_collection_api():
"""test mosaic collection."""
resp = httpx.get(
f"{raster_endpoint}/collections/noaa-emergency-response/-85.6358,36.1624/assets"
f"{raster_endpoint}/collections/noaa-emergency-response/point/-85.6358,36.1624/assets"
)
assert resp.status_code == 200
assert len(resp.json()) == 1
assert list(resp.json()[0]) == ["id", "bbox", "assets", "collection"]
assert resp.json()[0]["id"] == "20200307aC0853900w361030"

resp = httpx.get(
f"{raster_endpoint}/collections/noaa-emergency-response/tiles/15/8589/12849/assets"
f"{raster_endpoint}/collections/noaa-emergency-response/tiles/WebMercatorQuad/15/8589/12849/assets"
)
assert resp.status_code == 200
assert len(resp.json()) == 1
Expand All @@ -70,7 +72,7 @@ def test_mosaic_collection_api():

z, x, y = 15, 8589, 12849
resp = httpx.get(
f"{raster_endpoint}/collections/noaa-emergency-response/tiles/{z}/{x}/{y}",
f"{raster_endpoint}/collections/noaa-emergency-response/tiles/WebMercatorQuad/{z}/{x}/{y}",
params={"assets": "cog"},
headers={"Accept-Encoding": "br, gzip"},
timeout=10.0,
Expand Down Expand Up @@ -208,7 +210,7 @@ def test_item():
assert resp.json() == ["cog"]

resp = httpx.get(
f"{raster_endpoint}/collections/noaa-emergency-response/items/20200307aC0853300w361200/tilejson.json",
f"{raster_endpoint}/collections/noaa-emergency-response/items/20200307aC0853300w361200/WebMercatorQuad/tilejson.json",
params={
"assets": "cog",
},
Expand Down Expand Up @@ -238,9 +240,9 @@ def test_collections():


def test_cog_endpoints():
"""test /cog endpoints"""
"""test /external endpoints"""
resp = httpx.get(
f"{raster_endpoint}/cog/info",
f"{raster_endpoint}/external/info",
params={
"url": "https://noaa-eri-pds.s3.us-east-1.amazonaws.com/2020_Nashville_Tornado/20200307a_RGB/20200307aC0854500w361030n.tif",
},
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The dynamic tiler deployed within `eoapi-devseed` is built on top of [titiler-pg
The service includes all the default endpoints from **titiler-pgstac** application and:

- `/`: a custom landing page with links to the different endpoints
- `/mosaic/builder`: a virtual mosaic builder UI that helps create and register STAC Search queries
- `/searches/builder`: a virtual mosaic builder UI that helps create and register STAC Search queries
- `/collections`: a secret (not in OpenAPI documentation) endpoint used in the mosaic-builder page
- `/collections/{collection_id}/items/{item_id}/viewer`: a simple STAC Item viewer

Expand Down
21 changes: 5 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@ services:
environment:
- PYTHONUNBUFFERED=1
# Application
- HOST=0.0.0.0
- PORT=8081
- WEB_CONCURRENCY=10
- POSTGRES_USER=username
- POSTGRES_PASS=password
- POSTGRES_DBNAME=postgis
- POSTGRES_HOST_READER=database
- POSTGRES_HOST_WRITER=database
- POSTGRES_PORT=5432
- DB_MIN_CONN_SIZE=1
- DB_MAX_CONN_SIZE=10
- DB_MAX_CONN_SIZE=1
# - EOAPI_STAC_TITILER_ENDPOINT=raster
- EOAPI_STAC_TITILER_ENDPOINT=http://127.0.0.1:8082
# PgSTAC extensions
Expand All @@ -50,7 +47,7 @@ services:
required: false
depends_on:
- database
command: bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h database -p 5432 && /start.sh"
command: bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h database -p 5432 && uvicorn eoapi.stac.app:app --host 0.0.0.0 --port 8081 --workers 1"
develop:
watch:
- action: sync+restart
Expand All @@ -73,11 +70,6 @@ services:
environment:
- PYTHONUNBUFFERED=1
# Application
- HOST=0.0.0.0
- PORT=8082
- WEB_CONCURRENCY=1
- WORKERS_PER_CORE=1
- MAX_WORKERS=10
- POSTGRES_USER=username
- POSTGRES_PASS=password
- POSTGRES_DBNAME=postgis
Expand All @@ -104,7 +96,7 @@ services:
required: false
depends_on:
- database
command: bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h database -p 5432 && /start.sh"
command: bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h database -p 5432 && uvicorn eoapi.raster.app:app --host 0.0.0.0 --port 8082 --workers 10"
develop:
watch:
- action: sync+restart
Expand All @@ -124,9 +116,6 @@ services:
environment:
- PYTHONUNBUFFERED=1
# Application
- HOST=0.0.0.0
- PORT=8083
- WEB_CONCURRENCY=10
- POSTGRES_USER=username
- POSTGRES_PASS=password
- POSTGRES_DBNAME=postgis
Expand All @@ -140,7 +129,7 @@ services:
required: false
- path: .vector.env
required: false
command: bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h database -p 5432 && /start.sh"
command: bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h database -p 5432 && uvicorn eoapi.vector.app:app --host 0.0.0.0 --port 8083 --workers 10"
develop:
watch:
- action: sync+restart
Expand All @@ -154,7 +143,7 @@ services:
- ./dockerfiles/scripts:/tmp/scripts

database:
image: ghcr.io/stac-utils/pgstac:v0.8.5
image: ghcr.io/stac-utils/pgstac:v0.9.2
environment:
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
Expand Down
28 changes: 22 additions & 6 deletions dockerfiles/Dockerfile.raster
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
ARG PYTHON_VERSION=3.11
ARG PYTHON_VERSION=3.12

FROM ghcr.io/vincentsarago/uvicorn-gunicorn:${PYTHON_VERSION}
FROM bitnami/python:${PYTHON_VERSION}
RUN apt update && apt upgrade -y \
&& apt install curl -y \
&& rm -rf /var/lib/apt/lists/*

ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
# Ensure root certificates are always updated at evey container build
# and curl is using the latest version of them
RUN mkdir /usr/local/share/ca-certificates/cacert.org
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/root.crt
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/class3.crt
RUN update-ca-certificates
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

RUN python -m pip install psycopg[binary,pool]
RUN python -m pip install -U pip
RUN python -m pip install uvicorn uvicorn-worker gunicorn psycopg[binary,pool]

COPY runtimes/eoapi/raster /tmp/raster
RUN python -m pip install /tmp/raster
RUN rm -rf /tmp/raster

ENV MODULE_NAME eoapi.raster.app
ENV VARIABLE_NAME app
###################################################
# For compatibility (might be removed at one point)
ENV MODULE_NAME=eoapi.raster.app
ENV VARIABLE_NAME=app
ENV HOST=0.0.0.0
ENV PORT=80
ENV WEB_CONCURRENCY=1
CMD gunicorn -k uvicorn.workers.UvicornWorker ${MODULE_NAME}:${VARIABLE_NAME} --bind ${HOST}:${PORT} --workers ${WEB_CONCURRENCY}
28 changes: 23 additions & 5 deletions dockerfiles/Dockerfile.stac
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
ARG PYTHON_VERSION=3.11
ARG PYTHON_VERSION=3.12

FROM ghcr.io/vincentsarago/uvicorn-gunicorn:${PYTHON_VERSION}
FROM bitnami/python:${PYTHON_VERSION}
RUN apt update && apt upgrade -y \
&& apt install curl -y \
&& rm -rf /var/lib/apt/lists/*

ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
# Ensure root certificates are always updated at evey container build
# and curl is using the latest version of them
RUN mkdir /usr/local/share/ca-certificates/cacert.org
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/root.crt
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/class3.crt
RUN update-ca-certificates
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

RUN python -m pip install -U pip
RUN python -m pip install uvicorn uvicorn-worker gunicorn

COPY runtimes/eoapi/stac /tmp/stac
RUN python -m pip install /tmp/stac
RUN rm -rf /tmp/stac

ENV MODULE_NAME eoapi.stac.app
ENV VARIABLE_NAME app
###################################################
# For compatibility (might be removed at one point)
ENV MODULE_NAME=eoapi.stac.app
ENV VARIABLE_NAME=app
ENV HOST=0.0.0.0
ENV PORT=80
ENV WEB_CONCURRENCY=1
CMD gunicorn -k uvicorn.workers.UvicornWorker ${MODULE_NAME}:${VARIABLE_NAME} --bind ${HOST}:${PORT} --workers ${WEB_CONCURRENCY}
28 changes: 24 additions & 4 deletions dockerfiles/Dockerfile.vector
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
ARG PYTHON_VERSION=3.11
ARG PYTHON_VERSION=3.12

FROM ghcr.io/vincentsarago/uvicorn-gunicorn:${PYTHON_VERSION}
FROM bitnami/python:${PYTHON_VERSION}
RUN apt update && apt upgrade -y \
&& apt install curl -y \
&& rm -rf /var/lib/apt/lists/*

# Ensure root certificates are always updated at evey container build
# and curl is using the latest version of them
RUN mkdir /usr/local/share/ca-certificates/cacert.org
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/root.crt
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/class3.crt
RUN update-ca-certificates
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

RUN python -m pip install -U pip
RUN python -m pip install uvicorn uvicorn-worker gunicorn

COPY runtimes/eoapi/vector /tmp/vector
RUN python -m pip install /tmp/vector
RUN rm -rf /tmp/vector

ENV MODULE_NAME eoapi.vector.app
ENV VARIABLE_NAME app
###################################################
# For compatibility (might be removed at one point)
ENV MODULE_NAME=eoapi.vector.app
ENV VARIABLE_NAME=app
ENV HOST=0.0.0.0
ENV PORT=80
ENV WEB_CONCURRENCY=1
CMD gunicorn -k uvicorn.workers.UvicornWorker ${MODULE_NAME}:${VARIABLE_NAME} --bind ${HOST}:${PORT} --workers ${WEB_CONCURRENCY}
2 changes: 1 addition & 1 deletion dockerfiles/browser_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
apiCatalogPriority: null,
useTileLayerAsFallback: true,
displayGeoTiffByDefault: false,
buildTileUrlTemplate: ({href, asset}) => "http://0.0.0.0:8082/cog/tiles/{z}/{x}/{y}@2x?url=" + encodeURIComponent(asset.href.startsWith("/vsi") ? asset.href : href),
buildTileUrlTemplate: ({href, asset}) => "http://0.0.0.0:8082/external/tiles/WebMercatorQuad/{z}/{x}/{y}@2x?url=" + encodeURIComponent(asset.href.startsWith("/vsi") ? asset.href : href),
stacProxyUrl: null,
pathPrefix: "/",
historyMode: "history",
Expand Down
Loading
Loading