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.6.0.tar.gz (41.2 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.6.0-cp310-abi3-win_arm64.whl (28.2 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_containerfile-0.6.0-cp310-abi3-win_amd64.whl (29.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_containerfile-0.6.0-cp310-abi3-musllinux_1_2_x86_64.whl (56.3 kB view details)

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

tree_sitter_containerfile-0.6.0-cp310-abi3-musllinux_1_2_aarch64.whl (59.0 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_containerfile-0.6.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (57.3 kB view details)

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

tree_sitter_containerfile-0.6.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (61.1 kB view details)

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

tree_sitter_containerfile-0.6.0-cp310-abi3-macosx_11_0_arm64.whl (29.6 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

tree_sitter_containerfile-0.6.0-cp310-abi3-macosx_10_9_x86_64.whl (29.2 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.6.0.tar.gz
Algorithm Hash digest
SHA256 2cd5e621738465c1260f54ee70d72d4f1e8ea2ce414260d877afae7beab33339
MD5 c5cafc3af83faf138a8a49a1c5f3a028
BLAKE2b-256 0172c8db16393fd7fb3eac4308f6d651bb5c8062ad7906a5039e9ab2771a2b60

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.6.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.6.0-cp310-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.6.0-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 bdfd6e195fc539d6a8df195718aa6735050a443b448ce0d9999e55cf0b362ca2
MD5 8e93e25d86e7f9bd81816c838f933cfe
BLAKE2b-256 a08cdf8206e325e658c550655b6f7f117ba742ae7a8f628388413aad3eaa4ec7

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.6.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.6.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.6.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e7c17fd252d443ce8ab4ab162e94119edfcc076706f3fbd5476a065ac4d1c2fa
MD5 3ea9de3147f016f74362b1a1352e6f9b
BLAKE2b-256 322e166ea18582aaa2e8b0b1969c46ef75887e3185b8f7ac1416b13ddac471cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.6.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.6.0-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.6.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1e13ad9965119df80a4fe0ec9ff079bedb974105906697ea85e11eb141f8fccc
MD5 ccbdc333657c5c35f55010f0610bdb09
BLAKE2b-256 01121353073fa8e4d1c75b33e57b9d46c1a91b10803fddf0a3a33a13ffdbbff3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.6.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.6.0-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.6.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 b0e5420bdd833124840e9c38f3348b22ee8e251e9832adb85f46459917bd1c46
MD5 c0281f49da8feaec49f4834a433d8343
BLAKE2b-256 4070d04478020733ff65fe71f57b7b5282f7e80dee5d9fb39fd89a7c9a66d309

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.6.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.6.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.6.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 11b0f9a280605ba5fa28d3f08b1615c0272e90b5ded72fd4b7d7303dbc878ce7
MD5 acc32e459e275d08c83addb85b609a00
BLAKE2b-256 f1e3440cc48347a3aee51f12d77a03abe9cbef6aa3b92d219a5435db2db794a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.6.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.6.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.6.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9473b7cf078ee231aec98a5d1fadc958c49380244539a1f0a4e663bbc95b41e6
MD5 f6a4620d36f118b674bc216d665f2b44
BLAKE2b-256 a6f591a2a265a30558fe465eeb38ccd558fcc908358c69bdc57cfc472725ec52

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.6.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.6.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.6.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bcd59ded0043c4b0954920f3ec48c0a338bfe53e5e9e32078998b82f05e8982b
MD5 59f6b89f816127e79d4f6259d5d7d566
BLAKE2b-256 077f3bc88ff3a2d48c688a4cb39d75e6dd1e7425b75d11231edcb841180248a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.6.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.6.0-cp310-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.6.0-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9accba59c5f5cf896e38dc5f1b2d66bdc6f755ef1f782ee4386604ece5175243
MD5 8fa181791c562ba98270d4eae99eeb4d
BLAKE2b-256 9de00baa31c9a1c528de0dbd81975a0f013d2bb61ffbc4455013cf6e638af228

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.6.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