Skip to main content

A Containerfile and Dockerfile grammar for tree-sitter

Project description

tree-sitter-containerfile

A maintained Containerfile and Dockerfile grammar for tree-sitter.

This project is intended to be a reliable, actively maintained grammar for modern container build files, with published packages and generated bindings for Node.js, Python, Rust, Go, Swift, and C.

Why This Package

Containerfile and Dockerfile syntax continues to evolve across Docker, BuildKit, Podman, and related tooling. This grammar aims to close the gap for modern Dockerfile features, keep real-world fixtures parsing cleanly, and ship usable packages across the common tree-sitter binding ecosystems.

The historical tree-sitter-dockerfile npm package is not a dependable installation target: it currently resolves to a 0.0.1-security placeholder release. tree-sitter-containerfile is the maintained package name for this grammar and its generated artifacts.

Installation

npm

npm install tree-sitter-containerfile

PyPI

pip install tree-sitter-containerfile

Cargo

cargo add tree-sitter-containerfile

Go

import containerfile "github.com/wharflab/tree-sitter-containerfile"

Usage

Node.js

import Parser from "tree-sitter";
import Containerfile from "tree-sitter-containerfile";

const parser = new Parser();
parser.setLanguage(Containerfile);

const tree = parser.parse("FROM alpine:3.20\nRUN echo ok\n");
console.log(tree.rootNode.toString());

Python

from tree_sitter import Language, Parser
import tree_sitter_containerfile

parser = Parser(Language(tree_sitter_containerfile.language()))
tree = parser.parse(b"FROM alpine:3.20\nRUN echo ok\n")
print(tree.root_node.sexp())

Rust

let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_containerfile::LANGUAGE;
parser.set_language(&language.into()).unwrap();

let tree = parser.parse("FROM alpine:3.20\nRUN echo ok\n", None).unwrap();
println!("{}", tree.root_node().to_sexp());

Go

package main

import (
	"fmt"

	sitter "github.com/tree-sitter/go-tree-sitter"
	containerfile "github.com/wharflab/tree-sitter-containerfile"
)

func main() {
	parser := sitter.NewParser()
	defer parser.Close()

	_ = parser.SetLanguage(containerfile.GetLanguage())
	tree := parser.Parse([]byte("FROM alpine:3.20\nRUN echo ok\n"), nil)
	defer tree.Close()

	fmt.Println(tree.RootNode().ToSexp())
}

Development

npm ci
npm run generate
tree-sitter test

The test suite includes the upstream corpus and integration parsing of the real-world Containerfile fixtures in examples/.

Migration Notes

Spaced ENV values can span line continuations. Consumers that inspect unquoted_string children should handle line_continuation nodes in addition to expansion nodes, because the internal _spaced_env_value rule aliases those values to unquoted_string.

Credits

This grammar started from camdencheek/tree-sitter-dockerfile. The project is being maintained and extended here under the tree-sitter-containerfile package name.

License

Licensed under MIT.

The original MIT notice for the upstream grammar and fixtures is preserved in LICENSE-MIT-CamdenCheek.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tree_sitter_containerfile-0.8.0.tar.gz (48.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tree_sitter_containerfile-0.8.0-cp310-abi3-win_arm64.whl (31.6 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_containerfile-0.8.0-cp310-abi3-win_amd64.whl (33.2 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_containerfile-0.8.0-cp310-abi3-musllinux_1_2_x86_64.whl (65.7 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

tree_sitter_containerfile-0.8.0-cp310-abi3-musllinux_1_2_aarch64.whl (68.3 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_containerfile-0.8.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (66.5 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

tree_sitter_containerfile-0.8.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (70.1 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

tree_sitter_containerfile-0.8.0-cp310-abi3-macosx_11_0_arm64.whl (33.5 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

tree_sitter_containerfile-0.8.0-cp310-abi3-macosx_10_9_x86_64.whl (33.3 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

Details for the file tree_sitter_containerfile-0.8.0.tar.gz.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.0.tar.gz
Algorithm Hash digest
SHA256 f436a80b911dc3f82cabc9616a2798039844863314db08d8442606514517f5b1
MD5 a904ae06828c5d103998708507fdc14f
BLAKE2b-256 cf286f6d36da0c3c0860bbe18c8ce0db2272848e89770a3cc4b632336aab3de2

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.8.0.tar.gz:

Publisher: publish_pypi.yml on wharflab/tree-sitter-containerfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_containerfile-0.8.0-cp310-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.0-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 c510a50f1c9673a13332701f7e835855b4f3b54977209a0cd07c9f2ca382992f
MD5 50fdf2fb3cc37b9e0162fdb09db01068
BLAKE2b-256 9f5ac5eb560cb069221e3cf9608c29d18106167aaf9a1038e86aa65aa64426e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.8.0-cp310-abi3-win_arm64.whl:

Publisher: publish_pypi.yml on wharflab/tree-sitter-containerfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_containerfile-0.8.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8eaeada0892cff0748b19ae4c8759278ccd8342ce45c80bfb39df4cfd58f5e40
MD5 64cd0864f3373128d1a586ce7a5dd5c1
BLAKE2b-256 74d1a020031b27c3dbae29ef95f3922cd28cf4a783ad9141eade603c040f06c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.8.0-cp310-abi3-win_amd64.whl:

Publisher: publish_pypi.yml on wharflab/tree-sitter-containerfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_containerfile-0.8.0-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 41685ea42ba8d3ae2454bd856bf2e71df7a9ef927436b031d5baf407e979ab89
MD5 4329f4ac6a7b9320e4bea18ee201aa53
BLAKE2b-256 68538a0a9d7fab814b7e6deb8b6eb8b901506c7d667de6456413347f89c82a49

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.8.0-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: publish_pypi.yml on wharflab/tree-sitter-containerfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_containerfile-0.8.0-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 2fc1b0598c798d31f587f7e86371283ed46c00ab317d3dee5b72fdf0bdff0974
MD5 ed2f6b0dfb633a16a897a3ad8714b88d
BLAKE2b-256 22e4e57d345d5b7cf48f39bf81b074b600f24ed4d5cece5b2405b51781e2c9ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.8.0-cp310-abi3-musllinux_1_2_aarch64.whl:

Publisher: publish_pypi.yml on wharflab/tree-sitter-containerfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_containerfile-0.8.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e683c41b50afb3f14f0479d6353c455647410adb934e5739684ceb01a8f5e31
MD5 e84501a0a3a354b2ca42052635fe9dd9
BLAKE2b-256 89c17419a09bc19a2eddcf0a067539afd44eb749baea8e56e86ae3f4a412010f

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.8.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish_pypi.yml on wharflab/tree-sitter-containerfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_containerfile-0.8.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bbac642208528df3b035145ccd9a8b523e55f83b32fd392ea6c38434113b0c27
MD5 72180e578407fef7227d84c665876ce2
BLAKE2b-256 1d655eea385e3b49ee6076533434ddb2f9ff3c07236de50c72300cc4b7056212

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.8.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: publish_pypi.yml on wharflab/tree-sitter-containerfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_containerfile-0.8.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3cc9117b2fa95f943062d4ee233e33646a2e428a6f1ea384bdc977efd698959d
MD5 48a244ae2e930dbe345770a125e7ac0b
BLAKE2b-256 5fa9afc15b305436a022192b1e0b5b7c0da3d5948b8121d2880f0b245882e876

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.8.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: publish_pypi.yml on wharflab/tree-sitter-containerfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_containerfile-0.8.0-cp310-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.0-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 30f96dbe1615ca15d65a7b8ba2601d5cd28aa28e239a58678ffd3e5a9d44ec54
MD5 c1f0c30dbd344f98103eced6dcd58083
BLAKE2b-256 09908be805629c3f5b6a1b996118d3b9fca56bcae1b63123a330a2c37ba0dee6

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.8.0-cp310-abi3-macosx_10_9_x86_64.whl:

Publisher: publish_pypi.yml on wharflab/tree-sitter-containerfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page