Skip to content

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.

Terminal window
docker pull ghcr.io/xberg-io/tree-sitter-language-pack:latest
# Parse a file by mounting the current directory
docker run --rm \
-v "$(pwd):/work" -w /work \
ghcr.io/xberg-io/tree-sitter-language-pack:latest \
parse src/main.py
# From stdin
echo "def hello(): pass" | docker run --rm -i \
ghcr.io/xberg-io/tree-sitter-language-pack:latest \
parse - --language python

The image is two layers:

  1. A Rust/Alpine builder that compiles ts-pack-cli with all parsers statically linked via TSLP_LINK_MODE=static
  2. A minimal alpine:latest runtime containing /usr/local/bin/ts-pack

The binary links statically against musl libc, so it runs on any Linux machine without extra dependencies.

Before building, you need the parser C sources cloned locally:

Terminal window
uv run scripts/clone_vendors.py

Then build the image from the repository root (the full context must be present):

Terminal window
docker build -f docker/Dockerfile -t ts-pack .

The build takes several minutes — it compiles every grammar in sources/language_definitions.json from C.

Terminal window
docker run --rm ts-pack --version
docker run --rm ts-pack list | wc -l
# GitHub Actions
jobs:
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 --structure

Build 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 builder
RUN apk add --no-cache musl-dev gcc g++ python3 bash
WORKDIR /build
COPY . .
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:latest
COPY --from=builder /build/target/release/ts-pack /usr/local/bin/ts-pack
ENTRYPOINT ["ts-pack"]

Run uv run scripts/clone_vendors.py --languages python,javascript,typescript first to fetch the needed grammar sources.

The published image targets linux/amd64 and linux/arm64. The ci-docker.yaml and publish-docker.yaml workflows handle this via docker buildx.