Docker
The Docker image ships a statically-linked ts-pack binary on Alpine Linux.
The build process compiles all parsers at image build time; the container needs
no internet access or runtime downloads.
Quick start
Section titled “Quick start”docker pull ghcr.io/xberg-io/tree-sitter-language-pack:latest
# Parse a file by mounting the current directorydocker run --rm \ -v "$(pwd):/work" -w /work \ ghcr.io/xberg-io/tree-sitter-language-pack:latest \ parse src/main.py
# From stdinecho "def hello(): pass" | docker run --rm -i \ ghcr.io/xberg-io/tree-sitter-language-pack:latest \ parse - --language pythonImage contents
Section titled “Image contents”The image is two layers:
- A Rust/Alpine builder that compiles
ts-pack-cliwith all parsers statically linked viaTSLP_LINK_MODE=static - A minimal
alpine:latestruntime containing/usr/local/bin/ts-pack
The binary links statically against musl libc, so it runs on any Linux machine without extra dependencies.
Building locally
Section titled “Building locally”Before building, you need the parser C sources cloned locally:
uv run scripts/clone_vendors.pyThen build the image from the repository root (the full context must be present):
docker build -f docker/Dockerfile -t ts-pack .The build takes several minutes — it compiles every grammar in sources/language_definitions.json from C.
Verify the image
Section titled “Verify the image”docker run --rm ts-pack --versiondocker run --rm ts-pack list | wc -lUse in CI
Section titled “Use in CI”# GitHub Actionsjobs: analyze: runs-on: ubuntu-latest container: image: ghcr.io/xberg-io/tree-sitter-language-pack:latest steps: - uses: actions/checkout@v4 - name: Extract structure run: ts-pack process src/main.py --structureBuild a smaller image with a parser subset
Section titled “Build a smaller image with a parser subset”To target a language subset, set TSLP_LANGUAGES at build time:
FROM rust:alpine AS builderRUN apk add --no-cache musl-dev gcc g++ python3 bashWORKDIR /buildCOPY . .RUN TSLP_LANGUAGES=python,javascript,typescript \ TSLP_LINK_MODE=static \ PROJECT_ROOT=/build \ cargo build --release -p ts-pack-cli && \ strip target/release/ts-pack
FROM alpine:latestCOPY --from=builder /build/target/release/ts-pack /usr/local/bin/ts-packENTRYPOINT ["ts-pack"]Run uv run scripts/clone_vendors.py --languages python,javascript,typescript
first to fetch the needed grammar sources.
Multi-arch
Section titled “Multi-arch”The published image targets linux/amd64 and linux/arm64. The ci-docker.yaml
and publish-docker.yaml workflows handle this via docker buildx.