Skip to content

Commit

Permalink
add dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Mar 20, 2024
1 parent 1499b4f commit d19ad05
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 0 deletions.
91 changes: 91 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
version: '3'

services:
api:
# At the time of writing, rasterio wheels are not available for arm64 arch
# so we force the image to be built with linux/amd64
platform: linux/amd64
build:
context: .
dockerfile: dockerfiles/Dockerfile.gunicorn
ports:
- "8081:8081"
environment:
# Application
- HOST=0.0.0.0
- PORT=8081
- WEB_CONCURRENCY=1
- WORKERS_PER_CORE=1
# GDAL Config
# This option controls the default GDAL raster block cache size.
# If its value is small (less than 100000), it is assumed to be measured in megabytes, otherwise in bytes.
- GDAL_CACHEMAX=200
- GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR
- GDAL_INGESTED_BYTES_AT_OPEN=32768
- GDAL_HTTP_MERGE_CONSECUTIVE_RANGES=YES
- GDAL_HTTP_MULTIPLEX=YES
- GDAL_HTTP_VERSION=2
# The file can be cached in RAM by setting the configuration option VSI_CACHE to TRUE.
# The cache size defaults to 25 MB, but can be modified by setting the configuration option VSI_CACHE_SIZE (in bytes).
# Content in that cache is discarded when the file handle is closed.
- VSI_CACHE=TRUE
- VSI_CACHE_SIZE=536870912
# In addition, a global least-recently-used cache of 16 MB shared among all downloaded content is enabled by default,
# and content in it may be reused after a file handle has been closed and reopen,
# during the life-time of the process or until VSICurlClearCache() is called.
# Starting with GDAL 2.3, the size of this global LRU cache can be modified by
# setting the configuration option CPL_VSIL_CURL_CACHE_SIZE (in bytes).
- CPL_VSIL_CURL_CACHE_SIZE=200000000
# TiTiler Config
- MOSAIC_CONCURRENCY=5
# AWS S3 endpoint config
# - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
# - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
# TiTiler STAC API Config
- TITILER_STACAPI_API_DEBUG=TRUE
- TITILER_STACAPI_STAC_API_URL=

api-uvicorn:
# At the time of writing, rasterio wheels are not available for arm64 arch
# so we force the image to be built with linux/amd64
platform: linux/amd64
build:
context: .
dockerfile: dockerfiles/Dockerfile.uvicorn
ports:
- "8081:8081"
environment:
# Application
- HOST=0.0.0.0
- PORT=8081
- WEB_CONCURRENCY=1
# GDAL Config
- CPL_TMPDIR=/tmp
# This option controls the default GDAL raster block cache size.
# If its value is small (less than 100000), it is assumed to be measured in megabytes, otherwise in bytes.
- GDAL_CACHEMAX=200
- GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR
- GDAL_INGESTED_BYTES_AT_OPEN=32768
- GDAL_HTTP_MERGE_CONSECUTIVE_RANGES=YES
- GDAL_HTTP_MULTIPLEX=YES
- GDAL_HTTP_VERSION=2
# The file can be cached in RAM by setting the configuration option VSI_CACHE to TRUE.
# The cache size defaults to 25 MB, but can be modified by setting the configuration option VSI_CACHE_SIZE (in bytes).
# Content in that cache is discarded when the file handle is closed.
- VSI_CACHE=TRUE
- VSI_CACHE_SIZE=536870912
# In addition, a global least-recently-used cache of 16 MB shared among all downloaded content is enabled by default,
# and content in it may be reused after a file handle has been closed and reopen,
# during the life-time of the process or until VSICurlClearCache() is called.
# Starting with GDAL 2.3, the size of this global LRU cache can be modified by
# setting the configuration option CPL_VSIL_CURL_CACHE_SIZE (in bytes).
- CPL_VSIL_CURL_CACHE_SIZE=200000000
# TiTiler Config
- MOSAIC_CONCURRENCY=5
# - RIO_TILER_MAX_THREADS=2
# AWS S3 endpoint config
# - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
# - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
# TiTiler STAC API Config
- TITILER_STACAPI_API_DEBUG=TRUE
- TITILER_STACAPI_STAC_API_URL=
19 changes: 19 additions & 0 deletions dockerfiles/Dockerfile.gunicorn
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ARG PYTHON_VERSION=3.12

FROM ghcr.io/vincentsarago/uvicorn-gunicorn:${PYTHON_VERSION}


ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt

WORKDIR /tmp

COPY titiler/ titiler/
COPY pyproject.toml pyproject.toml
COPY README.md README.md
COPY LICENSE LICENSE

RUN python -m pip install --no-cache-dir --upgrade .
RUN rm -rf titiler/ pyproject.toml README.md LICENSE

ENV MODULE_NAME titiler.stacapi.main
ENV VARIABLE_NAME app
18 changes: 18 additions & 0 deletions dockerfiles/Dockerfile.uvicorn
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG PYTHON_VERSION=3.12

FROM python:${PYTHON_VERSION}-slim

WORKDIR /tmp

COPY titiler/ titiler/
COPY pyproject.toml pyproject.toml
COPY README.md README.md
COPY LICENSE LICENSE

RUN python -m pip install --no-cache-dir --upgrade . uvicorn
RUN rm -rf titiler/ pyproject.toml README.md LICENSE

# http://www.uvicorn.org/settings/
ENV HOST 0.0.0.0
ENV PORT 80
CMD uvicorn titiler.stacapi.main:app --host ${HOST} --port ${PORT}

0 comments on commit d19ad05

Please sign in to comment.