Sign inSign up

klhq/tdlib

By klhq

Updated 12 days ago

Image
0

739

klhq/tdlib repository overview

TDLib Docker Image

TDLib Version Docker Pulls Image Size Deployment

Prebuilt, multi-arch Docker images of TDLib (Telegram Database Library). Drop libtdjson.so into your bot, client, or service and skip the 30–60 minute TDLib compile.

docker pull klhq/tdlib        # Debian, glibc — default
docker pull klhq/tdlib:alpine # Alpine, musl — opt-in

Both variants ship linux/amd64 and linux/arm64.


Which tag should I pull?

Your stackPull this
Python (python:3.x, python:3.x-slim), Node (node:x, node:x-slim), Go (cgo), Java/Kotlin (JNI), bare-metal Ubuntu/Debian/RHEL/Archklhq/tdlib (Debian, glibc)
Everything on Alpine (python:3.x-alpine, node:x-alpine, static Go on musl)klhq/tdlib:alpine
Specific TDLib versionklhq/tdlib:1.8.64 (Debian) or klhq/tdlib:1.8.64-alpine

Compatibility rule: a shared library built against one libc cannot be loaded by a process running on the other. Pick the variant matching your consumer's libc — don't mix glibc and musl in the same image.

If unsure, pull the default (klhq/tdlib). It works for ~95% of real-world TDLib consumers.


Quick start

Three patterns, in order of how often they're used.

The canonical pattern. Your runtime image stays small; you just lift libtdjson.so.

Use a directory COPY (/usr/local/lib/), not a wildcard. Docker's COPY de-references symlinks when the source is a glob or a single symlink file, which turns the unversioned libtdjson.so link into a duplicate 33 MB regular file and breaks dlopen("libtdjson.so") on glibc. Copying the directory preserves the symlink and keeps the image small.

Python:

FROM klhq/tdlib:latest AS tdlib

FROM python:3.12-slim
COPY --from=tdlib /usr/local/lib/ /usr/local/lib/
RUN ldconfig
RUN pip install --no-cache-dir python-telegram
COPY app.py /app/
WORKDIR /app
CMD ["python", "app.py"]

Node.js:

FROM klhq/tdlib:latest AS tdlib

FROM node:20-slim
COPY --from=tdlib /usr/local/lib/ /usr/local/lib/
RUN ldconfig
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["node", "bot.js"]

Go (cgo bindings):

FROM klhq/tdlib:latest AS tdlib

FROM golang:1.22-bookworm
COPY --from=tdlib /usr/local/lib/ /usr/local/lib/
RUN ldconfig
WORKDIR /src
COPY . .
RUN go build -o /bot ./cmd/bot
CMD ["/bot"]

Python (Alpine consumer — :alpine variant):

The Alpine image is built with clang/libc++, so Alpine consumers must install those runtime libraries explicitly.

FROM klhq/tdlib:alpine AS tdlib

FROM python:3.12-alpine
RUN apk add --no-cache libssl3 zlib libc++ libgcc llvm-libunwind
COPY --from=tdlib /usr/local/lib/ /usr/local/lib/
RUN pip install --no-cache-dir python-telegram
COPY app.py /app/
WORKDIR /app
CMD ["python", "app.py"]
Pattern B — FROM klhq/tdlib as a base

Simpler when your app is mostly TDLib glue. You inherit Debian + the lib in one shot.

FROM klhq/tdlib:latest
USER root
RUN apt-get update && apt-get install -y --no-install-recommends python3 python3-pip \
 && rm -rf /var/lib/apt/lists/*
USER app
COPY app.py /app/
CMD ["python3", "/app/app.py"]
Pattern C — Extract libtdjson.so for bare-metal / CI use

Pull the lib out of the image and drop it next to a binary running on a VM, CI runner, or developer laptop.

docker create --name td-extract klhq/tdlib:latest
docker cp td-extract:/usr/local/lib/. ./tdlib-libs/   # trailing /. copies directory contents and preserves symlinks
docker rm td-extract
sudo cp -P ./tdlib-libs/* /usr/local/lib/ && sudo ldconfig

The trailing /. matters: docker cp follows a symlink if you point it at one directly, but copies the symlink-as-symlink when you copy a directory's contents. After installing to /usr/local/lib, cp -P preserves the symlink, and ldconfig registers both libtdjson.so and the versioned SONAME in the loader cache.

The extracted .so is a standard glibc shared library — usable on any modern glibc Linux (Ubuntu 22.04+, Debian 12+, RHEL/Rocky 9+, Arch, Fedora). For Alpine hosts, extract from :alpine instead.


Compatibility matrix

TDLib variantConsumer image / hostWorks?
klhq/tdlib (Debian, glibc)python:3.x / python:3.x-slim
klhq/tdlib (Debian, glibc)node:x / node:x-slim
klhq/tdlib (Debian, glibc)golang:1.x-bookworm
klhq/tdlib (Debian, glibc)openjdk:x / eclipse-temurin:x
klhq/tdlib (Debian, glibc)Ubuntu 22.04+ / Debian 12+ / RHEL 9+ host
klhq/tdlib (Debian, glibc)*-alpine consumer
klhq/tdlib:alpine (musl)*-alpine consumer
klhq/tdlib:alpine (musl)glibc consumer (slim, bookworm, ubuntu, etc.)

glibc is forward-compatible: the Debian variant (built on bookworm, glibc 2.36) runs anywhere with glibc ≥ 2.36. For older systems (Ubuntu 20.04, RHEL 8), build the image locally on debian:bullseye — see Building locally.


What's inside the image

Debian variantAlpine variant
Basedebian:bookworm-slimalpine:3.21
libcglibc 2.36musl 1.2.5
C++ runtimelibstdc++ (gcc)libc++ (clang)
Library/usr/local/lib/libtdjson.sosame
Usernon-root appsame
Headers / static libsstripped (consumers use dlopen + the JSON ABI)same
Approx compressed size~30 MB~26 MB

Both variants link OpenSSL 3 and zlib dynamically. Debug symbols are stripped.


All tags

TagVariantArchitectures
latestDebianamd64 + arm64
1.8.64Debianamd64 + arm64
1.8.64-debianDebian (explicit alias)amd64 + arm64
debianDebian (latest version)amd64 + arm64
alpineAlpine (latest version)amd64 + arm64
1.8.64-alpineAlpineamd64 + arm64

Full list: hub.docker.com/r/klhq/tdlib/tags.


Building locally

# Debian variant (default)
docker buildx build -f Dockerfile -t tdlib-local .

# Alpine variant
docker buildx build -f Dockerfile.alpine -t tdlib-local-alpine .

# Multi-arch (requires QEMU + buildx setup)
docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile -t tdlib-local .

To target an older glibc, swap the base images in Dockerfile from bookworm to bullseye (glibc 2.31, covers Ubuntu 20.04).


Versioning

The image version tracks TDLib upstream's version, sourced from CMakeLists.txt (project(TDLib VERSION X.Y.Z ...)). Releases are tagged on GitHub when upstream cuts a new version; CI then builds and pushes the matching Docker tags.

See GitHub Releases for per-version changelogs.


Breaking change: default variant is now Debian

klhq/tdlib:latest previously pointed to the Alpine-based (musl) image. It now points to the Debian-based (glibc) variant, which matches the libc of the overwhelming majority of TDLib consumers (Python, Node, Go cgo, Java, Ubuntu/Debian/RHEL hosts).

If you were relying on the Alpine variant, pin to klhq/tdlib:alpine for the moving Alpine tag, or klhq/tdlib:<version>-alpine for a versioned pin.


Resources

License

TDLib is licensed under the Boost Software License 1.0. The Docker packaging in this repository is provided under the same license.

Tag summary

Content type

Image

Digest

sha256:b2d06b58c

Size

54.3 MB

Last updated

12 days ago

docker pull klhq/tdlib