Skip to content

Commit 3cbc2e1

Browse files
committed
2 parents 3c19285 + 138282a commit 3cbc2e1

8 files changed

Lines changed: 1217 additions & 959 deletions

File tree

‎dockerfiles/Dockerfile‎

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,95 @@
1+
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:3754b6da0e1ccdab0fe46abfdd7bbbba994b593c28149f6659fa6597f2261aeb AS base
2+
13
ARG PYTHON_VERSION=3.14
24

3-
FROM python:${PYTHON_VERSION} AS builder
5+
ENV PYTHONUNBUFFERED=1
46

5-
# Set build labels
6-
LABEL stage=builder
7-
LABEL org.opencontainers.image.source="https://github.com/developmentseed/titiler"
8-
LABEL org.opencontainers.image.description="TiTiler"
9-
LABEL org.opencontainers.image.licenses="MIT"
7+
# Install runtime dependencies. Versions deliberately unpinned: Wolfi rolls
8+
# forward and garbage-collects old versions, so an "=<version>" pin breaks the
9+
# build within days. The guardrails are the version-scoped names plus the
10+
# digest above. No pip: uv (below) installs everything.
11+
# libstdc++ NOT optional: the rasterio/pyproj/duckdb manylinux wheels list
12+
# libstdc++.so.6 in DT_NEEDED and auditwheel does not vendor it.
13+
# bash, tzdata, curl parity with the old Debian base: /bin/sh is busybox,
14+
# Wolfi ships no /usr/share/zoneinfo, curl is for in-pod debugging.
15+
RUN apk add --no-cache \
16+
python-${PYTHON_VERSION} \
17+
libstdc++ bash tzdata curl libexpat1
18+
19+
# uv as a pass-through stage rather than a direct COPY --from=<image>:
20+
# Dependabot only parses FROM lines (dependabot/dependabot-core#5103), so this
21+
# keeps the version pinned *and* auto-updated by the docker ecosystem.
22+
FROM ghcr.io/astral-sh/uv:0.12.5@sha256:e85be844203885286c60ffad8a858d48afb6c5a5c237ca0e67f12e74b8f174b1 AS uv
1023

11-
# Set environment variables
12-
ENV PYTHONUNBUFFERED=1 \
13-
PYTHONDONTWRITEBYTECODE=1
24+
# Build stage
25+
FROM base AS builder
1426

15-
# Install build dependencies
16-
RUN apt-get update && \
17-
apt-get install -y --no-install-recommends \
18-
libexpat1 curl && \
19-
rm -rf /var/lib/apt/lists/*
27+
ARG PYTHON_VERSION
2028

2129
# Install uv
22-
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
30+
COPY --from=uv /uv /uvx /usr/local/bin/
2331

2432
# Configure uv-managed virtual environment
33+
# UV_PYTHON: the apk python's version, but resolved by uv (not the apk
34+
# binary itself: Wolfi's rolling python-3.14 build has repeatedly required
35+
# a newer glibc than the glibc package available in the same repo snapshot,
36+
# making /usr/bin/python3.14 unable to import stdlib extension modules).
37+
# uv instead downloads its own self-contained, statically-linked build.
38+
# UV_PYTHON_INSTALL_DIR: put that managed interpreter next to /opt/venv (both
39+
# get copied into the runtime stage below) — otherwise it lands under
40+
# /root/.local/share/uv, which never reaches the runtime stage, leaving
41+
# /opt/venv/bin/python (and every venv script's shebang, eg uvicorn) a
42+
# dangling symlink: `exec .../uvicorn: no such file or directory`.
43+
# UV_COMPILE_BYTECODE: .pyc at install time, as pip did, so cold starts
44+
# don't pay the compile on first import
2545
ENV UV_LINK_MODE=copy \
2646
UV_PROJECT_ENVIRONMENT=/opt/venv \
47+
UV_PYTHON=${PYTHON_VERSION} \
48+
UV_PYTHON_INSTALL_DIR=/opt/uv-python \
49+
UV_COMPILE_BYTECODE=1 \
2750
PATH="/opt/venv/bin:${PATH}"
2851

29-
WORKDIR /tmp
52+
WORKDIR /tmp/app
3053

31-
# Copy project metadata and code
54+
# Copy project metadata and dependencies
3255
COPY pyproject.toml uv.lock README.md LICENSE ./
3356
COPY src/titiler/ ./src/titiler/
57+
58+
# Install project dependencies into the uv-managed virtual environment.
59+
# --no-editable: the runtime stage only copies /opt/venv (and /opt/uv-python),
60+
# not this /tmp/app source tree, so editable installs (.pth files pointing
61+
# back at /tmp/app) would leave `import titiler...` broken at runtime.
3462
RUN uv sync --frozen --no-dev --no-editable --group server
3563
RUN uv pip install --no-deps --no-editable .
3664

65+
# uv skips downloading its own managed interpreter when the apk python already
66+
# satisfies UV_PYTHON, leaving UV_PYTHON_INSTALL_DIR absent. Make sure it
67+
# exists (even empty) so the unconditional COPY below never fails.
68+
RUN mkdir -p /opt/uv-python
69+
3770
# Runtime stage
38-
FROM python:${PYTHON_VERSION}-slim
71+
FROM base
3972

4073
# Set runtime labels
4174
LABEL org.opencontainers.image.source="https://github.com/developmentseed/titiler"
4275
LABEL org.opencontainers.image.description="TiTiler"
4376
LABEL org.opencontainers.image.licenses="MIT"
4477

45-
# Set environment variables
46-
ENV PYTHONUNBUFFERED=1 \
47-
PYTHONDONTWRITEBYTECODE=1 \
48-
PATH="/opt/venv/bin:$PATH"
78+
# The chart execs `command: ["uvicorn"]` — a bare binary, resolved against the
79+
# image's PATH.
80+
ENV PATH="/opt/venv/bin:${PATH}"
4981

50-
# Install runtime dependencies
51-
RUN apt-get update && \
52-
apt-get install -y --no-install-recommends \
53-
libexpat1 curl && \
54-
rm -rf /var/lib/apt/lists/*
55-
56-
# Copy virtual environment from builder
82+
# Copy virtual environment and its interpreter from builder
5783
COPY --from=builder /opt/venv /opt/venv
84+
COPY --from=builder /opt/uv-python /opt/uv-python
5885

59-
RUN groupadd -g 1000 user && \
60-
useradd -u 1000 -g user -s /bin/bash -m user
86+
WORKDIR /tmp
6187

62-
USER user
88+
# Run as the wolfi-base nonroot user (uid 65532). On Kubernetes the chart sets
89+
# the net.ipv4.ip_unprivileged_port_start sysctl per pod.
90+
# Other deployments must allow unprivileged low ports the same way,
91+
# or override PORT to something >=1024.
92+
USER nonroot
6393

6494
###################################################
6595
# For compatibility (might be removed at one point)

‎dockerfiles/Dockerfile.xarray‎

Lines changed: 88 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,98 @@
1+
# WARNING: This image is deprecated and will be removed in 3.0.
2+
3+
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:3754b6da0e1ccdab0fe46abfdd7bbbba994b593c28149f6659fa6597f2261aeb AS base
4+
15
ARG PYTHON_VERSION=3.14
26

3-
FROM python:${PYTHON_VERSION}
4-
RUN apt update && apt upgrade -y \
5-
&& apt install curl -y \
6-
&& rm -rf /var/lib/apt/lists/*
7+
ENV PYTHONUNBUFFERED=1
8+
9+
# Install runtime dependencies. Versions deliberately unpinned: Wolfi rolls
10+
# forward and garbage-collects old versions, so an "=<version>" pin breaks the
11+
# build within days. The guardrails are the version-scoped names plus the
12+
# digest above. No pip: uv (below) installs everything.
13+
# libstdc++ NOT optional: the rasterio/pyproj/duckdb manylinux wheels list
14+
# libstdc++.so.6 in DT_NEEDED and auditwheel does not vendor it.
15+
# bash, tzdata, curl parity with the old Debian base: /bin/sh is busybox,
16+
# Wolfi ships no /usr/share/zoneinfo, curl is for in-pod debugging.
17+
RUN apk add --no-cache \
18+
python-${PYTHON_VERSION} \
19+
libstdc++ bash tzdata curl libexpat1
20+
21+
# uv as a pass-through stage rather than a direct COPY --from=<image>:
22+
# Dependabot only parses FROM lines (dependabot/dependabot-core#5103), so this
23+
# keeps the version pinned *and* auto-updated by the docker ecosystem.
24+
FROM ghcr.io/astral-sh/uv:0.12.5@sha256:e85be844203885286c60ffad8a858d48afb6c5a5c237ca0e67f12e74b8f174b1 AS uv
25+
26+
# Build stage
27+
FROM base AS builder
28+
29+
ARG PYTHON_VERSION
30+
31+
# Install uv
32+
COPY --from=uv /uv /uvx /usr/local/bin/
733

8-
# Ensure root certificates are always updated at evey container build
9-
# and curl is using the latest version of them
10-
# RUN mkdir /usr/local/share/ca-certificates/cacert.org
11-
# RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/root.crt
12-
# RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/class3.crt
13-
# ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
14-
RUN update-ca-certificates
34+
# Configure uv-managed virtual environment
35+
# UV_PYTHON: the apk python's version, but resolved by uv (not the apk
36+
# binary itself: Wolfi's rolling python-3.14 build has repeatedly required
37+
# a newer glibc than the glibc package available in the same repo snapshot,
38+
# making /usr/bin/python3.14 unable to import stdlib extension modules).
39+
# uv instead downloads its own self-contained, statically-linked build.
40+
# UV_PYTHON_INSTALL_DIR: put that managed interpreter next to /opt/venv (both
41+
# get copied into the runtime stage below) — otherwise it lands under
42+
# /root/.local/share/uv, which never reaches the runtime stage, leaving
43+
# /opt/venv/bin/python (and every venv script's shebang, eg uvicorn) a
44+
# dangling symlink: `exec .../uvicorn: no such file or directory`.
45+
# UV_COMPILE_BYTECODE: .pyc at install time, as pip did, so cold starts
46+
# don't pay the compile on first import
47+
ENV UV_LINK_MODE=copy \
48+
UV_PROJECT_ENVIRONMENT=/opt/venv \
49+
UV_PYTHON=${PYTHON_VERSION} \
50+
UV_PYTHON_INSTALL_DIR=/opt/uv-python \
51+
UV_COMPILE_BYTECODE=1 \
52+
PATH="/opt/venv/bin:${PATH}"
1553

16-
RUN python -m pip install -U pip
17-
RUN python -m pip install uvicorn uvicorn-worker gunicorn
54+
WORKDIR /tmp/app
1855

19-
COPY src/titiler/ /tmp/titiler/
20-
RUN python -m pip install /tmp/titiler/core["telemetry"] /tmp/titiler/xarray --no-cache-dir --upgrade
21-
RUN rm -rf /tmp/titiler
56+
# Copy project metadata and dependencies
57+
COPY pyproject.toml uv.lock README.md LICENSE ./
58+
COPY src/titiler/ ./src/titiler/
2259

60+
# Install project dependencies into the uv-managed virtual environment.
61+
# --no-editable: the runtime stage only copies /opt/venv (and /opt/uv-python),
62+
# not this /tmp/app source tree, so editable installs (.pth files pointing
63+
# back at /tmp/app) would leave `import titiler...` broken at runtime.
64+
RUN uv sync --frozen --no-dev --no-editable --group server
65+
RUN uv pip install --no-deps --no-editable /tmp/app/src/titiler/core["telemetry"] /tmp/app/src/titiler/xarray
66+
67+
# uv skips downloading its own managed interpreter when the apk python already
68+
# satisfies UV_PYTHON, leaving UV_PYTHON_INSTALL_DIR absent. Make sure it
69+
# exists (even empty) so the unconditional COPY below never fails.
70+
RUN mkdir -p /opt/uv-python
71+
72+
# Runtime stage
73+
FROM base
74+
75+
# Set runtime labels
2376
LABEL deprecated=TRUE
77+
LABEL org.opencontainers.image.source="https://github.com/developmentseed/titiler"
78+
LABEL org.opencontainers.image.description="TiTiler Xarray"
79+
LABEL org.opencontainers.image.licenses="MIT"
80+
81+
# The chart execs `command: ["uvicorn"]` — a bare binary, resolved against the
82+
# image's PATH.
83+
ENV PATH="/opt/venv/bin:${PATH}"
84+
85+
# Copy virtual environment and its interpreter from builder
86+
COPY --from=builder /opt/venv /opt/venv
87+
COPY --from=builder /opt/uv-python /opt/uv-python
88+
89+
WORKDIR /tmp
90+
91+
# Run as the wolfi-base nonroot user (uid 65532). On Kubernetes the chart sets
92+
# the net.ipv4.ip_unprivileged_port_start sysctl per pod.
93+
# Other deployments must allow unprivileged low ports the same way,
94+
# or override PORT to something >=1024.
95+
USER nonroot
2496

2597
###################################################
2698
# For compatibility (might be removed at one point)

‎pyproject.toml‎

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ classifiers = [
3030
]
3131
version="2.2.2"
3232
dependencies = [
33-
"titiler-core",
34-
"titiler-xarray",
35-
"titiler-extensions",
33+
"titiler-core[telemetry]",
34+
"titiler-xarray[fs]",
35+
"titiler-extensions[cogeo,stac]",
3636
"titiler-mosaic[mosaicjson]",
3737
"titiler-application",
3838
]
@@ -42,17 +42,8 @@ dev = [
4242
"pytest",
4343
"pytest-cov",
4444
"pytest-asyncio",
45-
"httpx2",
46-
"obstore",
47-
"zarr>=3,<4.0",
48-
"h5netcdf",
49-
"h5py",
50-
"fsspec",
51-
"s3fs>=2025.2.0",
52-
"aiohttp",
53-
"requests",
45+
"brotlicffi",
5446
"pystac[validation]>=1.0.0,<2.0.0",
55-
"brotlipy",
5647
"boto3",
5748
"owslib",
5849
"pre-commit",
@@ -61,13 +52,6 @@ dev = [
6152
"matplotlib",
6253
"folium",
6354
]
64-
telemetry = [
65-
"opentelemetry-api",
66-
"opentelemetry-sdk",
67-
"opentelemetry-instrumentation-fastapi",
68-
"opentelemetry-instrumentation-logging",
69-
"opentelemetry-exporter-otlp",
70-
]
7155
docs = [
7256
"black>=23.10.1",
7357
"mkdocs>=1.4.3",

‎src/titiler/application/pyproject.toml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ test = [
4848
"pytest",
4949
"pytest-cov",
5050
"pytest-asyncio",
51-
"httpx2",
52-
"brotlipy",
51+
"brotlicffi",
5352
"boto3",
5453
]
5554

‎src/titiler/extensions/pyproject.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ test = [
4747
"pytest",
4848
"pytest-cov",
4949
"pytest-asyncio",
50-
"httpx2",
5150
"pystac[validation]>=1.0.0,<2.0.0",
5251
"owslib",
5352
]

‎src/titiler/mosaic/pyproject.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ test = [
4343
"pytest",
4444
"pytest-cov",
4545
"pytest-asyncio",
46-
"httpx2",
4746
"owslib",
4847
]
4948

‎src/titiler/xarray/pyproject.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ dependencies = [
3636
"zarr>=3.1,<4.0",
3737
"starlette-cramjam>=0.4,<1.0",
3838
"pydantic-settings~=2.0",
39-
"httpx2",
4039
]
4140

4241
[project.optional-dependencies]

0 commit comments

Comments
 (0)