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.1.tar.gz (48.3 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.1-cp310-abi3-win_arm64.whl (31.8 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_containerfile-0.8.1-cp310-abi3-win_amd64.whl (32.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_containerfile-0.8.1-cp310-abi3-musllinux_1_2_x86_64.whl (65.9 kB view details)

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

tree_sitter_containerfile-0.8.1-cp310-abi3-musllinux_1_2_aarch64.whl (68.5 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_containerfile-0.8.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (66.7 kB view details)

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

tree_sitter_containerfile-0.8.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (70.3 kB view details)

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

tree_sitter_containerfile-0.8.1-cp310-abi3-macosx_11_0_arm64.whl (33.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

tree_sitter_containerfile-0.8.1-cp310-abi3-macosx_10_9_x86_64.whl (33.5 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.1.tar.gz
Algorithm Hash digest
SHA256 f043f650e82f5dbda92bf16d1adfff5aee237e2a9159e9fe2e2d8f4718fec146
MD5 57374ce08892d8c84341d8060120d890
BLAKE2b-256 d7dca4018759e8e7cd14e77315620d13215162a1bae02fefcda7fdf9281843df

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.1-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 e0efd32718ac00527f351ccfaa469419cbbc75d7113113b7f129ff92ba755fba
MD5 237f8fba1160bb210c65ca5fb292bbcd
BLAKE2b-256 a35e077ee6e02efa696782c2010d51ca17d324464605541c2c58abda71a7b3f8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 afa285a299ac176e805864040ad5144a7b39e94554114b0f9f4a91b22a6b8717
MD5 9208e10cb0ba8a0798cbbc0090e79eab
BLAKE2b-256 a75ff6d0784da38d0462051fea20c631448fdb23e4ebd2b5373821b01936ab43

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c85d945621e15cef9a5dab86e76e75db34b8a5402531d12fb1c3ae261380e57f
MD5 d4f55acd02e7ac9a4e31326096a51e02
BLAKE2b-256 f7cd677d6e2a7c61f53ca699ae77283c8a9d67db7480d5b32b6a5eb9c404d6c7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 400ed1953373cb5cf2cf6bcf02c6c613ea60b22e83eebdd8072383bf5db56ab4
MD5 18c0959d333fafa4c785de8d8ef4b397
BLAKE2b-256 2797e0f45ab543c7ecc3bd5d962fc96586c8e40c5d6e976dc3a78ad339bd8e11

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.8.1-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.1-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.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 60230fdcc6f157cf188810f1d0b8a4f8029325f2764daf0f3cca659195b4083b
MD5 104d3688a76a52abff268cfffbf027fb
BLAKE2b-256 9ea6457b9006da9ba8fa25fecf64a5585301eafeb2a4ce51d045b39e5ccc538b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d25e86cdeb5c002825072ca056fecfdfb8d6d0337b4317a5d09761f70f0e442a
MD5 34918d59c95ee8984c6c6db7cbbd206d
BLAKE2b-256 11e01d9d4b25dea05c176fb67c40d04442df41878703ef777a02271427440d65

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0787c93df44fedef8d7cef12e8f27b8de7ed8ff10d7eaea955fe0de98543f7f9
MD5 e6b8e37c87db7db93f9f394bd7300c66
BLAKE2b-256 0a83b26f4f1e5b5c54656b2727663890addac9322f4f5335f31995525e528e3f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.8.1-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b6f4f58d180738448243d67ce29a218e05d5ec6b3e22d00a6f4b11885f8888b5
MD5 a5c6ea02035d2b7a81104e1737c06f19
BLAKE2b-256 2f994dcc778108ea526a95e7aa8570dce14e7a86d0663e7995b644f31c84bd77

See more details on using hashes here.

Provenance

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