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.7.0.tar.gz (41.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.7.0-cp310-abi3-win_arm64.whl (28.3 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_containerfile-0.7.0-cp310-abi3-win_amd64.whl (29.8 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_containerfile-0.7.0-cp310-abi3-musllinux_1_2_x86_64.whl (57.3 kB view details)

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

tree_sitter_containerfile-0.7.0-cp310-abi3-musllinux_1_2_aarch64.whl (60.1 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_containerfile-0.7.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (58.2 kB view details)

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

tree_sitter_containerfile-0.7.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (62.1 kB view details)

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

tree_sitter_containerfile-0.7.0-cp310-abi3-macosx_11_0_arm64.whl (29.8 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

tree_sitter_containerfile-0.7.0-cp310-abi3-macosx_10_9_x86_64.whl (29.3 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.7.0.tar.gz
Algorithm Hash digest
SHA256 bb5ce68c608a7e7d619c0d0447d3ec180feeb8de0f575e65aa0782c7aef86c69
MD5 9824554fd260ee384264ff94316fff2f
BLAKE2b-256 d4e5cb9a50ce1ff23b447a21924d2c299df76837b47d4993267adb3e0b543ae2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.7.0-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 0baaefad8c15370fa2e6e7943c0e3f594ecd0a19f054a77d85d20a350c876c81
MD5 5ced3de016528416194e86c783a4c159
BLAKE2b-256 4bacc8a8469b2a8ddd69cf334c5beb61a00c6c22eb7d3aa0ee15dcd04e3dd557

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.7.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c8f6b138843ac9d4d41dc864ddd0c5bfd88c9c3957bda521a665a34cacae163b
MD5 d2674701eafec424ab5bea74b895fe22
BLAKE2b-256 513e8c634b1311fe4de96cf5a1cf50a752f257bf1db244a667558c6f78acacb8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.7.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c72cb8dc7cc2cd85e2b5d98eb031a210320829cce5db4fb464a0b7fe52f2abf5
MD5 c704ee3040eea1eb9cd738683644b8d8
BLAKE2b-256 332bc00f45adea972b918d947350393629db1b0378adb15dc64bacfc2f2cb87c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.7.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 309aab192c030a2d2fd84f6b3bbb4c2dd71f96b90a887f1db76d00bdaa4f14f3
MD5 f525408a829ddb115e1e982fd0c05ec3
BLAKE2b-256 e92a2bacc1ea4fbbe9c87890fb63c6d9ff25ec11a4abbaa2824161822c51e162

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.7.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.7.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.7.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 59c68af45951aef9608b68de8a896d93648d01445440ceec8a896359af9b19dd
MD5 29936ac76fbb2595435a205a1ff96a5e
BLAKE2b-256 0c60bd99d2435f62dd237b735f6745656524eb371dfd11eec5fda5aa965dceee

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.7.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5237665f55a506ff1d62917abbe9d97321ca5a80001f63befcf391bab2544edd
MD5 983d7d66faa3edbd0146569342c7e2c9
BLAKE2b-256 ab6f4ff0fb200a50e8669a57b840e9523c0e2fb1c79b7ffecfff14ab392a72d5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.7.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ca62dbf7f8c76a4023186056fd6fa12f2d4879ad33775c374cf6c572070bb28
MD5 4a32673e015dc0d6f86086c104eb4ffd
BLAKE2b-256 961758e46fb5d806b0c851c81c08578001cfc5f231510245279828a1b926cfd7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.7.0-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1e2f8b41d64f0d99d403ced3435b6331b1544d6c8191d85cdc582079e1910ead
MD5 b64d41b7588c6637d83b9e6a50d360e5
BLAKE2b-256 0775f70280168a17772a054cdf2ba690b5e2231526d0a8f3ce0571c74d623158

See more details on using hashes here.

Provenance

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