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.9.1.tar.gz (57.0 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.9.1-cp310-abi3-win_arm64.whl (37.1 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_containerfile-0.9.1-cp310-abi3-win_amd64.whl (37.9 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_containerfile-0.9.1-cp310-abi3-musllinux_1_2_x86_64.whl (57.5 kB view details)

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

tree_sitter_containerfile-0.9.1-cp310-abi3-musllinux_1_2_aarch64.whl (57.6 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_containerfile-0.9.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (57.6 kB view details)

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

tree_sitter_containerfile-0.9.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (58.6 kB view details)

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

tree_sitter_containerfile-0.9.1-cp310-abi3-macosx_11_0_arm64.whl (36.9 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

tree_sitter_containerfile-0.9.1-cp310-abi3-macosx_10_9_x86_64.whl (35.4 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.1.tar.gz
Algorithm Hash digest
SHA256 4ff52ee4082e9a9aff002db115edb5eecc7528c30cadc15a80074f5f86ea8025
MD5 bef78b694b20b5fd526ce476e64b212d
BLAKE2b-256 8a1ddb90894dac6d37a8e263b77317d302ab7be2dd1c28d9ab262af56de30988

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.1-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 e58e303271a6a1582cc063207049512b742428c9730b07e721586f8505363474
MD5 40d98ead1b91108ad12a753a9aa2cc56
BLAKE2b-256 bf5c6eb44207d175fbf0c91a15905f5da845023f595bed8d3d5cb80dd5762973

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 413bed29469ca6ee437dcde85cfef0883d66819d663f9af626f845051fd6df88
MD5 4b47cc223e7fb2f6ac92a7031a6ebba9
BLAKE2b-256 91d3ab5dcc965fc69b4c2f2aceed6d5c5800b47d50b32e41cce987ae38d4f6e3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 dd957812a7b5a4e83908d395057d759611048423803a5815b4ab891b0ba47b8e
MD5 2eb2a80e6f5d69c89f019e37b40094a2
BLAKE2b-256 33cefe1eb1687df1a9fb730cbdb7338a1e9f9cdaca10823e3ac68f1812316b89

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 6995ec82d35f2c8ac55d3300977a2ceae84079146f33c38ee587ad2db139b02e
MD5 148f7aba579ee41275f6e4c15e4286b6
BLAKE2b-256 f4e55d244b11d4bd04632bbb17161b90a28812505310f5d500e4dd1f11ed381a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.9.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.9.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.9.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 25cbbf69e223d11910188420674a2dd80032af3d8c4cb26b72313a36e57b9fea
MD5 d343be4c61b0c7fa2bb881812a0c66a6
BLAKE2b-256 ce6117f035f2535d8a7676c599dbc9c87113e47d2899b9c11dc4713e5bf6bc5a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6642fee18de3917975bdbc9d89fec394e078b96e106f1a0650ea3a1c8c594f71
MD5 7de02cc87ed61cc5df2e253721c505c2
BLAKE2b-256 5b42d9dd61c6ce41fc1a6cbe0c20eb7724aef48dd5b72e9960314e33540fe4d7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ef1f5b6709bcb0377909d87b77aab86fe51b97dc4cabf00649cf54e51c80fd8
MD5 b4e9c13aaba6b5d4ebceb6e80421dfd6
BLAKE2b-256 ceb5cc5a0f73c0721763279750234caccfa6d16fa6bda3c4cdd0ca4f37643ab3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.1-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b87a42863150ba25d10f1c44729c765ce19ec4852135c965a6a38b047c3459a5
MD5 924b37ce91b97d5a0be60208b2029ab9
BLAKE2b-256 d5c18d8a1d970d71b360bfbc79c75b1eb15b54ad720ef4fc8b1f629726976e1e

See more details on using hashes here.

Provenance

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