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.2.tar.gz (58.2 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.2-cp310-abi3-win_arm64.whl (37.4 kB view details)

Uploaded CPython 3.10+Windows ARM64

tree_sitter_containerfile-0.9.2-cp310-abi3-win_amd64.whl (38.2 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_containerfile-0.9.2-cp310-abi3-musllinux_1_2_x86_64.whl (58.5 kB view details)

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

tree_sitter_containerfile-0.9.2-cp310-abi3-musllinux_1_2_aarch64.whl (58.5 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

tree_sitter_containerfile-0.9.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (58.6 kB view details)

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

tree_sitter_containerfile-0.9.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (59.4 kB view details)

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

tree_sitter_containerfile-0.9.2-cp310-abi3-macosx_11_0_arm64.whl (37.4 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

tree_sitter_containerfile-0.9.2-cp310-abi3-macosx_10_9_x86_64.whl (35.8 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.2.tar.gz
Algorithm Hash digest
SHA256 c7365153fcb37d9ad09453a165d8e768e998e0e09928158a37aabed0698700b9
MD5 128954a1730c405db6e7c7aa3a931261
BLAKE2b-256 0787b5a407d7d9fa3a989c01db022e43383d10ade8c94a6d86a0a714b797e536

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.2-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 b7ee3d8c0fc718a9aca787e2d96e383a62f3a6ba65780debde908ff2beb5287c
MD5 556fb9a020ed2475c5e93d440b5b8157
BLAKE2b-256 f4ab9b3ce56465664b75bd923be8429a0825df7bc672f2e4ed26544dc2867bd2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3e2487743ddbaad2f255f9b17b93b7d97f466992b4627baafb3fe80e7ed4beab
MD5 77552a62d8b1b84f2cd2daeb30d0e484
BLAKE2b-256 7f82ebc862ec8fcc1d698e76b04d0c174e7c96233be9a66bee0d5cdcda40890a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.2-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 93d9bab4f7a39508a6b2954e2bded6a47f68d4bdf4e533532c11a387c65f0ad3
MD5 5305a69a2aab78b86bada2ae54333d36
BLAKE2b-256 a23ad575af8ff40f3c7fce3842160f52b2c4748ce52bbe6c5325e8ff08234459

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.2-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 6e46a9226826f78abe1fe84c05eac8e808ce38e74d86cbf5db42f6d7e67cacab
MD5 23caff16e3171be4587f57634544d263
BLAKE2b-256 9f849524ef81d48d5a2b488d7eeae1dd42f67136408cc52327b3f2868be70dec

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_containerfile-0.9.2-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.2-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.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2aea1b436deb7d3d595a52da0885285bb2f61f0778da8ff37a2e2b77d3382ed4
MD5 4aaf87c8b4aae2c34b12c72d5bbb2db2
BLAKE2b-256 4c956e57d042508f6319cf06c99d924c90363a399c178a8cb378749eaacfc48f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 329778ceb55904b3472072bd4fcf8d9666d69297be5e7fae8beb494bae0eae74
MD5 6bf91bd9683fdd6e79b95c0abddde3b3
BLAKE2b-256 e1d12682ef208f26f04ca433959c1ee2b856e1f13d61e129d9312e666472a69b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 434f068285951f3bb84db600f7eafa1c1389ee9c7ad0c97498fcb8f4c26a0a52
MD5 096cf11fad65dbf7efe4462de070c814
BLAKE2b-256 8560931d935aeca9486211ecd23111babe4a85f0a22e872dec5b0d18e5430ffd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_containerfile-0.9.2-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 93b905d981de46bba3bbb810bfe16c7ee5888a10cbb6cbb40c25b13edcdf58b9
MD5 8385e394896839d2b107a01abf0c0c25
BLAKE2b-256 c7f4fbf66d0b858d8ae17af4b7e1741e9bf1245995b855ab56c23f3a095dacdb

See more details on using hashes here.

Provenance

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