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/.

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.3.1.tar.gz (48.6 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.3.1-cp310-abi3-win_arm64.whl (31.5 kB view details)

Uploaded CPython 3.10+Windows ARM64

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

Uploaded CPython 3.10+Windows x86-64

tree_sitter_containerfile-0.3.1-cp310-abi3-musllinux_1_2_x86_64.whl (58.9 kB view details)

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

tree_sitter_containerfile-0.3.1-cp310-abi3-musllinux_1_2_aarch64.whl (60.4 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_containerfile-0.3.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (59.4 kB view details)

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

tree_sitter_containerfile-0.3.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (61.7 kB view details)

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

tree_sitter_containerfile-0.3.1-cp310-abi3-macosx_11_0_arm64.whl (33.1 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

tree_sitter_containerfile-0.3.1-cp310-abi3-macosx_10_9_x86_64.whl (33.1 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.3.1.tar.gz
Algorithm Hash digest
SHA256 340c87324ad30716f7169adc6a5e9a19220fe19da1afa0ac1e23cbe7b3e94a04
MD5 1570b0861976cfc4e45f21682bf2c6f3
BLAKE2b-256 e11d3f7da0679119b94eab0e5e7fa31d7e308f04a5619d2dfbd981db777d0a04

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.3.1-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 092358a45d5e0e7b12a85cefd97125768ee9cc13daa20ec42b270be993b25335
MD5 f2f9d024e4caa929656831a27d4bc6fe
BLAKE2b-256 392c3aa36a85d04573a22a22688d7170618c13e5db730904a31aed116cac50cb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.3.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 86e6a6abab1afe23beb6747e2a82ec25b1266440d41b704c6361d5facfd3ba24
MD5 b50ee930a0b0d7ffba90ae8e53d6d7be
BLAKE2b-256 24e20bc9ccbd60ce3da60e44ff3cd6d98dbaff16b82c40eec7c14eb8069f6256

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.3.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 df039f43c84f2df9c208d79d824ad27ac772746ab2ad9e60d041c5b895e41abf
MD5 044f615fe895d1a9ad8a9e3a6998216f
BLAKE2b-256 45490b1d00233492465c61332b9fa72222623639c9ac5617ed09c6432a179e88

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.3.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 4037c5ac24adb76189cb90306bdbdf29f714f1b5e377a775fa9352b4e78bdada
MD5 85d80d3a1b92c345a1f745e3ad1217dc
BLAKE2b-256 f9cfa71fa0ffcbb83145b5bd29effb728d10d4324330df67f2eee2d234bcd0bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.3.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.3.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.3.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bc7ba952a156677405007fd5dd6cc7f03cf92847ab96d3194a7f638c12addd2b
MD5 e9bac10275cc1919eada3615e13b94ae
BLAKE2b-256 f67c2e63cf593437c9f298143aca84f85a38860db57dba01b8332a79c531262f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.3.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bcd3a266cd50d0fe7ba3897948a7065c3c11b1d039100b08ea058878a044646a
MD5 a282c9b7195940e6a696c4c6cba7a308
BLAKE2b-256 f9620bc09b08e0123ca63392efa86d3a706419b44b129ffb666303f3ca5cebfe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.3.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dad76a1d131f345fa2a2b31e930a65156f2afb2f1b149d573bb5f7988038f089
MD5 de7f63554e6f3e2386e44fe5acf704c8
BLAKE2b-256 78871cfff1c8fcbfb3380a22683a93f000aa82c2dd2b4eb4c439d8787ecb02b8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.3.1-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 af947e9d20aaaca61c71e97b38c7a07be29330b269669a73b8dc60dd18023a02
MD5 b2709977a117c7d0a676f6a73b42c366
BLAKE2b-256 bcba1ac003b1b68f423cde06d312cfc5d61c1ff452ccee0a9635627080906978

See more details on using hashes here.

Provenance

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