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.4.0.tar.gz (50.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.4.0-cp310-abi3-win_arm64.whl (33.2 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_containerfile-0.4.0-cp310-abi3-win_amd64.whl (34.5 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_containerfile-0.4.0-cp310-abi3-musllinux_1_2_x86_64.whl (45.2 kB view details)

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

tree_sitter_containerfile-0.4.0-cp310-abi3-musllinux_1_2_aarch64.whl (45.7 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_containerfile-0.4.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (45.3 kB view details)

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

tree_sitter_containerfile-0.4.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (46.2 kB view details)

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

tree_sitter_containerfile-0.4.0-cp310-abi3-macosx_11_0_arm64.whl (32.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

tree_sitter_containerfile-0.4.0-cp310-abi3-macosx_10_9_x86_64.whl (31.3 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b16fe19701a63ab5b3da4a7a71e67efc8ae1e31732349a251845fcb64e27fe78
MD5 5bd2f2e1cb8e7c10a58a3634cc0c8163
BLAKE2b-256 3a14e6d26a79a66dc02d7b33b1a280d1f66cf0802d2d2fc692ad349908586b88

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.4.0-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 0ff1f68d0fb9d58d465bcb62adde3ca5b32c4d93d49808e4f57201cfbbf24a3b
MD5 bc8ff0d654f98f0577ebcd1685c1ea56
BLAKE2b-256 a4e81687df76802127d9183b01e5543c7564e1a99f5df5f694ec58c40ccd131e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.4.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ddcf51889a9c96dfed2f8138f0e77117ccb3fcddfc856a4b8c6540dd3a4d36d1
MD5 ad9545586b848f60b922abfc19ec45d4
BLAKE2b-256 03b85ecd8bb5e0d7757cc0ac900681702cba40d0b2ee0fabb759b41b084b159d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.4.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 edbc9ee6c397de6e7bebccd3f2f5de7a052396c5660af46070abf6c778375fce
MD5 41a166ac227a56657c30db7be16efa0e
BLAKE2b-256 c86b3e5cdd7c38f0c0dc01f2cbe9c183568550da3b7bfe5df2017e29562c01d4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.4.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 eb183ab91b157b6a810fd691d4c047da741ef718d59ef0f20f7fbddaf2c4548b
MD5 960dc729757d7e71a5e607116898c666
BLAKE2b-256 6058ebcc46a427ff2a184436eb04b3fd1042f73b1c5cd8604b76166f1b37f7fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.4.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.4.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.4.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a55a733480b4bea6574e7d4aa5b373b657fc92c839bd87b41fdff16079dd7ddb
MD5 cf6822a935f8cc498c1f63b736cf2510
BLAKE2b-256 aea5f484a43c3e62433b0b747ea7ce8e4f08c3879fc53b8b246e380922ab7ae2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.4.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7a7fd9a5251877b58bfa10f699b6f6569e52476c87aa8c09c341b2af60d3ae47
MD5 8d3c48a8e31cec0321a2b8fd6ae597d3
BLAKE2b-256 333e542ce7675da4bf233498d0ffebc70e4c06ccf9a08bbe647f363439e4a5d2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 78df385df9d462f24dcbd873e7ca660f22fc39bad7971afbc5caf78867111ccb
MD5 115390af4456f0ab4e8e93c689736a8c
BLAKE2b-256 14e1f35252953986fc49467f60f7e9f548ba560a7235836805dc0ff3b480ab37

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.4.0-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ac7eef1119b59fd83aa8fb8906fe0a71e414b92a0988a1cc8051a9a87c8c9acc
MD5 9949366be9b18d402888567b44fad1c8
BLAKE2b-256 2d7aba131714ae8e8974db930e2cad82af44adcc9ecc3cebbfe13165cf5765ae

See more details on using hashes here.

Provenance

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