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.5.0.tar.gz (50.8 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.5.0-cp310-abi3-win_arm64.whl (34.2 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_containerfile-0.5.0-cp310-abi3-win_amd64.whl (35.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_containerfile-0.5.0-cp310-abi3-musllinux_1_2_x86_64.whl (46.4 kB view details)

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

tree_sitter_containerfile-0.5.0-cp310-abi3-musllinux_1_2_aarch64.whl (46.9 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_containerfile-0.5.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (46.5 kB view details)

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

tree_sitter_containerfile-0.5.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (47.4 kB view details)

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

tree_sitter_containerfile-0.5.0-cp310-abi3-macosx_11_0_arm64.whl (33.8 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

tree_sitter_containerfile-0.5.0-cp310-abi3-macosx_10_9_x86_64.whl (32.3 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.5.0.tar.gz
Algorithm Hash digest
SHA256 95340c77e157c6cda9e87299ba154e9bb956ac4cffffff45e0a29aaa32b4533c
MD5 fae94499ef752a89285bf64bc89b7e6f
BLAKE2b-256 8833b6d8547ca3e5554543c849f09fa9fd0e5b29206b91c30595639f7e18cda8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.5.0-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 59ebf28219fa95c1bfd6670fa8e80fca2bcf72967bd25fee0b89a82eac559702
MD5 a5a387253398dd5a935c7ad2ad8f0c74
BLAKE2b-256 72cce7c6fd2f30eed9d4b9cd6a483ff37b8e9aa5150f91bd04308e2bbbe9f1ed

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.5.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 54e447a343439cb2285ed993837ec4e6062cf9e038789c2ec5c3860af0b1914f
MD5 c570441df35292eafb8bb556b4fa17ef
BLAKE2b-256 171ee7d3d3328fb23aa9ee235d8f3d168d9485326020d988c9f361b08deb978a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.5.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3f9d4a1abaa6c34997906790eb83e101bba2a8d0447fe0f0853125f3a8f4744b
MD5 bf859f73bcc7347f7a6fa90a7b586152
BLAKE2b-256 e92f158dd1cde57eb71e3c631dcb3f04731d17dc0e7e49c97a9d248fc0b4a2cc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.5.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a1bfa5e0e843aaabbf61dc081c98f90af5039defdc05cb8f7ddb40cc34f75bb4
MD5 40ebc58648ce91301282dc5f964f4b92
BLAKE2b-256 d33d8ec447e5801646d5e57de09af956a4c306a4966694f87145488f550b844c

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.5.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.5.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.5.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 16e77e1f18f4c9d790da98a143551d00bd703567204bda9f4ebac1f7825c3b7b
MD5 f087d53cf22dba5046a668a41145c5bf
BLAKE2b-256 75bcc9971692339573e44822f34e0e50e3ebd4e9d8902d330f03d149659e7934

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.5.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a62f76920c2efc9c232764a37fc3323f5af23c615b6ccc2ab3cb1d1346646bcf
MD5 1b10fa1e6fd0e3b6effac686d435e161
BLAKE2b-256 a2730a2766b89a43b09879be588d3b3ca4662130ee12a0c9c7f84933b794f562

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.5.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 707afd0e0ce407d01b209e6c33453ec8a0eee998efa0865d09046fccbfd264ec
MD5 41b6e80d8dab45628e41280a447d846f
BLAKE2b-256 9a9d7cd27a28b8f6891f2f7e4360a7c21433ead91d9f86f60789fd344e4ddb4f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.5.0-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4c05e86873346424c93f863c88a05c90fd011dc5f6215fd1f9741b365bbffd61
MD5 2d977da9542c05d8e903274797590b34
BLAKE2b-256 2e6069f4757c6a6002d01cc35f96921c067c1440e2caaefd5e1e1cbd2aaa4acc

See more details on using hashes here.

Provenance

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