Skip to content

Commit 5fab604

Browse files
create uniq docker image (#1067)
* create uniq docker image * remove test values file and update image repository in values.yaml * update deployment configuration to use command and args from values.yaml * refactor deployment configuration to use array syntax for command and args in values.yaml * update changelog and ensure compatibility * update python for ci --------- Co-authored-by: Emmanuel Mathot <[email protected]>
1 parent ef26bb1 commit 5fab604

File tree

12 files changed

+93
-184
lines changed

12 files changed

+93
-184
lines changed

.github/workflows/check_charts.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
# See https://github.com/developmentseed/titiler/discussions/387
6363
platforms: linux/amd64
6464
context: .
65-
file: dockerfiles/Dockerfile.uvicorn
65+
file: dockerfiles/Dockerfile
6666
push: false
6767
tags: "titiler:dev"
6868

.github/workflows/ci.yml

+5-32
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,8 @@ jobs:
141141
username: ${{ github.actor }}
142142
password: ${{ secrets.GITHUB_TOKEN }}
143143

144-
- name: Docker meta (unicorn)
145-
id: meta-uvicorn
146-
uses: docker/metadata-action@v5
147-
with:
148-
images: |
149-
ghcr.io/${{ github.repository }}-uvicorn
150-
flavor: |
151-
latest=false
152-
tags: |
153-
type=semver,pattern={{version}}
154-
type=raw,value=latest,enable={{is_default_branch}}
155-
156-
- name: Docker meta (gunicorn)
157-
id: meta-gunicorn
144+
- name: Docker meta
145+
id: meta
158146
uses: docker/metadata-action@v5
159147
with:
160148
images: |
@@ -165,31 +153,16 @@ jobs:
165153
type=semver,pattern={{version}}
166154
type=raw,value=latest,enable={{is_default_branch}}
167155
168-
# Uvicorn
169-
- name: Build and push uvicorn
170-
uses: docker/build-push-action@v6
171-
with:
172-
# TODO: add `linux/arm64 once https://github.com/rasterio/rasterio-wheels/issues/69 is resolved
173-
platforms: linux/amd64 # ,linux/arm64
174-
context: .
175-
file: dockerfiles/Dockerfile.uvicorn
176-
push: ${{ github.event_name != 'pull_request' }}
177-
tags: ${{ steps.meta-uvicorn.outputs.tags }}
178-
labels: ${{ steps.meta-uvicorn.outputs.labels }}
179-
cache-from: type=gha
180-
cache-to: type=gha,mode=max
181-
182-
# Gunicorn
183156
- name: Build and push
184157
uses: docker/build-push-action@v6
185158
with:
186159
# TODO: add `linux/arm64 once https://github.com/rasterio/rasterio-wheels/issues/69 is resolved
187160
platforms: linux/amd64 # ,linux/arm64
188161
context: .
189-
file: dockerfiles/Dockerfile.gunicorn
162+
file: dockerfiles/Dockerfile
190163
push: ${{ github.event_name != 'pull_request' }}
191-
tags: ${{ steps.meta-gunicorn.outputs.tags }}
192-
labels: ${{ steps.meta-gunicorn.outputs.labels }}
164+
tags: ${{ steps.meta.outputs.tags }}
165+
labels: ${{ steps.meta.outputs.labels }}
193166
cache-from: type=gha
194167
cache-to: type=gha,mode=max
195168

CHANGES.md

+45
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
# Release Notes
22

3+
## Unreleased
4+
5+
### Misc
6+
7+
* Unify Docker images (deprecate `titiler-uvicorn`)
8+
9+
```
10+
# Uvicorn
11+
# before
12+
docker run \
13+
--platform=linux/amd64 \
14+
-p 8000:8000 \
15+
--env PORT=8000 \
16+
--rm -it ghcr.io/developmentseed/titiler-uvicorn:latest
17+
18+
# now
19+
docker run \
20+
--platform=linux/amd64 \
21+
-p 8000:8000 \
22+
--rm -it ghcr.io/developmentseed/titiler:latest \
23+
uvicorn titiler.application.main:app --host 0.0.0.0 --port 8000 --workers 1
24+
25+
# Gunicorn
26+
# before
27+
docker run \
28+
--platform=linux/amd64 \
29+
-p 8000:8000 \
30+
--env PORT=8000 \
31+
--rm -it ghcr.io/developmentseed/titiler:latest
32+
33+
# now
34+
docker run \
35+
--platform=linux/amd64 \
36+
-p 8000:8000 \
37+
--rm -it ghcr.io/developmentseed/titiler:latest \
38+
gunicorn -k uvicorn.workers.UvicornWorker titiler.application.main:app --bind 0.0.0.0:8000 --workers 1
39+
```
40+
341
## 0.20.1 (2025-01-09)
442
543
### titiler.xarray
@@ -42,6 +80,13 @@
4280
* Remove `python3.8` support (author @pratapvardhan, https://github.com/developmentseed/titiler/pull/1058)
4381
* Add `python3.13` support (author @pratapvardhan, https://github.com/developmentseed/titiler/pull/1058)
4482
83+
## 0.19.3 (2025-01-09)
84+
85+
### titiler.xarray
86+
87+
* pin python zarr to >2,<3.0 to avoid zarr 3.0 breaking changes [Backported from 0.20.1]
88+
89+
4590
## 0.19.2 (2024-11-28)
4691
4792
### Misc

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,21 @@ Ready to use/deploy images can be found on Github registry.
105105
- https://github.com/developmentseed/titiler/pkgs/container/titiler
106106

107107
```bash
108-
docker run --name titiler \
108+
docker run
109+
--platform=linux/amd64 \
109110
-p 8000:8000 \
110-
--env PORT=8000 \
111-
--env WORKERS_PER_CORE=1 \
112-
--rm -it ghcr.io/developmentseed/titiler:latest
111+
--rm -it ghcr.io/developmentseed/titiler:latest \
112+
uvicorn titiler.application.main:app --host 0.0.0.0 --port 8000 --workers 1
113113
```
114114

115115
- Built the docker locally
116116
```
117117
git clone https://github.com/developmentseed/titiler.git
118118
cd titiler
119119
120-
docker compose up --build titiler # or titiler-uvicorn
120+
docker compose up --build titiler
121121
```
122122

123-
Some options can be set via environment variables, see: https://github.com/tiangolo/uvicorn-gunicorn-docker#advanced-usage
124-
125123
## Project structure
126124

127125
```

deployment/k8s/charts/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
appVersion: 0.20.1
33
description: A dynamic Web Map tile server
44
name: titiler
5-
version: 1.1.8
5+
version: 1.2.0
66
icon: https://raw.githubusercontent.com/developmentseed/titiler/main/docs/logos/TiTiler_logo_small.png
77
maintainers:
88
- name: emmanuelmathot # Emmanuel Mathot

deployment/k8s/charts/templates/deployment.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ spec:
2020
- name: {{ .Chart.Name }}
2121
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
2222
imagePullPolicy: {{ .Values.image.pullPolicy }}
23+
command: [ {{ .Values.image.command }} ]
24+
args: [ {{- range $arg := .Values.image.args }}
25+
{{- $arg | quote }},
26+
{{- end }}
27+
]
2328
securityContext:
2429
{{- toYaml .Values.securityContext | nindent 12 }}
2530
env:
@@ -37,7 +42,7 @@ spec:
3742
{{- end }}
3843
ports:
3944
- name: http
40-
containerPort: {{ .Values.env.PORT }}
45+
containerPort: 80
4146
protocol: TCP
4247
livenessProbe:
4348
httpGet:

deployment/k8s/charts/values-test.yaml

-55
This file was deleted.

deployment/k8s/charts/values.yaml

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@
22
replicaCount: 1
33

44
image:
5-
repository: ghcr.io/developmentseed/titiler-uvicorn
5+
repository: ghcr.io/developmentseed/titiler
66
tag: latest
77
pullPolicy: IfNotPresent
8+
command: "uvicorn"
9+
args:
10+
- "titiler.application.main:app"
11+
- "--host"
12+
- "0.0.0.0"
13+
- "--port"
14+
- "80"
15+
- "--workers"
16+
- "1"
817

918
nameOverride: ""
1019
fullnameOverride: ""
@@ -38,7 +47,6 @@ extraHostPathMounts: []
3847
imagePullSecrets: []
3948

4049
env:
41-
PORT: 80
4250
CPL_TMPDIR: /tmp
4351
GDAL_CACHEMAX: 200 # 200 mb
4452
VSI_CACHE: "TRUE"
@@ -48,7 +56,6 @@ env:
4856
GDAL_HTTP_MULTIPLEX: "YES"
4957
GDAL_HTTP_VERSION: 2
5058
PYTHONWARNINGS: "ignore"
51-
WEB_CONCURRENCY: 2
5259

5360
resources:
5461
limits:

docker-compose.yml

+5-54
Original file line numberDiff line numberDiff line change
@@ -5,62 +5,13 @@ services:
55
platform: linux/amd64
66
build:
77
context: .
8-
dockerfile: dockerfiles/Dockerfile.gunicorn
8+
dockerfile: dockerfiles/Dockerfile
99
ports:
1010
- "8000:8000"
11+
command: ["uvicorn", "titiler.application.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]
12+
# Or Using Gunicorn
13+
# command: ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "titiler.application.main:app", "--bind", "0.0.0.0:8000", "--workers", "1"]
1114
environment:
12-
# Application
13-
- HOST=0.0.0.0
14-
- PORT=8000
15-
# Gunicorn / Uvicorn
16-
# https://github.com/tiangolo/uvicorn-gunicorn-docker#web_concurrency
17-
- WEB_CONCURRENCY=1
18-
# https://github.com/tiangolo/uvicorn-gunicorn-docker#workers_per_core
19-
- WORKERS_PER_CORE=1
20-
# GDAL config
21-
- CPL_TMPDIR=/tmp
22-
- GDAL_CACHEMAX=75%
23-
- GDAL_INGESTED_BYTES_AT_OPEN=32768
24-
- GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR
25-
- GDAL_HTTP_MERGE_CONSECUTIVE_RANGES=YES
26-
- GDAL_HTTP_MULTIPLEX=YES
27-
- GDAL_HTTP_VERSION=2
28-
- PYTHONWARNINGS=ignore
29-
- VSI_CACHE=TRUE
30-
- VSI_CACHE_SIZE=536870912
31-
# GDAL VSI Config
32-
# https://gdal.org/user/virtual_file_systems.html#vsis3-aws-s3-files
33-
# https://gdal.org/user/virtual_file_systems.html#vsigs-google-cloud-storage-files
34-
# https://gdal.org/user/virtual_file_systems.html#vsiaz-microsoft-azure-blob-files
35-
# - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
36-
# - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
37-
# TiTiler config
38-
# - TITILER_API_DISABLE_STAC=TRUE/FALSE
39-
# - TITILER_API_DISABLE_MOSAIC=TRUE/FALSE
40-
# - TITILER_API_DISABLE_COG=TRUE/FALSE
41-
# - TITILER_API_CORS_ORIGIN=url.io,url.xyz
42-
# - TITILER_API_CACHECONTROL=public, max-age=3600
43-
# - TITILER_API_DEBUG=TRUE/FALSE
44-
# - MOSAIC_CONCURRENCY= # will default to `RIO_TILER_MAX_THREADS`
45-
# rio-tiler config
46-
# - RIO_TILER_MAX_THREADS=
47-
48-
titiler-uvicorn:
49-
# TODO: remove once https://github.com/rasterio/rasterio-wheels/issues/69 is resolved
50-
# See https://github.com/developmentseed/titiler/discussions/387
51-
platform: linux/amd64
52-
build:
53-
context: .
54-
dockerfile: dockerfiles/Dockerfile.uvicorn
55-
ports:
56-
- "8000:8000"
57-
environment:
58-
# Application
59-
- HOST=0.0.0.0
60-
- PORT=8000
61-
# Uvicorn
62-
# http://www.uvicorn.org/settings/#production
63-
- WEB_CONCURRENCY=1
6415
# GDAL config
6516
- CPL_TMPDIR=/tmp
6617
- GDAL_CACHEMAX=75%
@@ -91,7 +42,7 @@ services:
9142

9243
benchmark:
9344
extends:
94-
service: titiler-uvicorn
45+
service: titiler
9546
volumes:
9647
- ./.github/data:/data
9748

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Dockerfile for running titiler application with uvicorn server
2-
ARG PYTHON_VERSION=3.11
1+
ARG PYTHON_VERSION=3.12
32

43
FROM bitnami/python:${PYTHON_VERSION}
54
RUN apt update && apt upgrade -y \
@@ -12,13 +11,20 @@ RUN mkdir /usr/local/share/ca-certificates/cacert.org
1211
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/root.crt
1312
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/class3.crt
1413
RUN update-ca-certificates
15-
ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
14+
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
1615

17-
COPY src/titiler/ /tmp/titiler/
1816
RUN python -m pip install -U pip
19-
RUN python -m pip install /tmp/titiler/core /tmp/titiler/extensions["cogeo,stac"] /tmp/titiler/mosaic /tmp/titiler/application["server"] --no-cache-dir --upgrade
17+
RUN python -m pip install uvicorn uvicorn-worker gunicorn
18+
19+
COPY src/titiler/ /tmp/titiler/
20+
RUN python -m pip install /tmp/titiler/core /tmp/titiler/extensions["cogeo,stac"] /tmp/titiler/mosaic /tmp/titiler/application --no-cache-dir --upgrade
2021
RUN rm -rf /tmp/titiler
2122

22-
ENV HOST 0.0.0.0
23-
ENV PORT 80
24-
CMD uvicorn titiler.application.main:app --host ${HOST} --port ${PORT}
23+
###################################################
24+
# For compatibility (might be removed at one point)
25+
ENV MODULE_NAME=titiler.application.main
26+
ENV VARIABLE_NAME=app
27+
ENV HOST=0.0.0.0
28+
ENV PORT=80
29+
ENV WEB_CONCURRENCY=1
30+
CMD gunicorn -k uvicorn.workers.UvicornWorker ${MODULE_NAME}:${VARIABLE_NAME} --bind ${HOST}:${PORT} --workers ${WEB_CONCURRENCY}

0 commit comments

Comments
 (0)