e2b-dockerfile-utils
Dockerfile parser and shell lexer ported from BuildKit and a .dockerignore matcher ported from moby/patternmatcher, with no runtime dependencies. Used by the E2B SDK to implement Template.from_dockerfile and to filter the build context.
from e2b_dockerfile_utils import ShellLex, parse_dockerfile_ast
ast = parse_dockerfile_ast(
"""
FROM node:24 AS build
ENV KEY="a b" OTHER=c
RUN <<EOF
npm ci
npm run build
EOF
"""
)
for instruction in ast.instructions:
print(instruction.name, instruction.flags, instruction.args)
lex = ShellLex(ast.escape_token)
lex.process_words('KEY="a b" OTHER=c') # ['KEY=a b', 'OTHER=c']
parse_dockerfile_ast handles parser directives (# escape=, # syntax=), comments (including inside line continuations), builder flags, JSON/exec forms and heredocs, and reports line numbers and warnings. ShellLex splits and unquotes words the way BuildKit does, preserving $VAR / ${VAR:-default} references for later expansion.
from e2b_dockerfile_utils import PatternMatcher
matcher = PatternMatcher(["node_modules", "*.log", "!keep.log"])
matcher.matches("node_modules/pkg/index.js") # True
matcher.matches("keep.log") # False
PatternMatcher applies .dockerignore semantics to slash-separated paths relative to the context root: a pattern matching a directory excludes everything under it, and ! patterns re-include paths (the last matching pattern wins). An invalid pattern raises a plain ValueError.
Metadata
Release files for e2b-dockerfile-utils 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| e2b_dockerfile_utils-0.1.0.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| e2b_dockerfile_utils-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.7 kB
Release files / e2b_dockerfile_utils-0.1.0.tar.gz
| Download URL | e2b_dockerfile_utils-0.1.0.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f840a3e30b2e4140ef4ebb67013a399b568ce4bf62de9f9c1d069d3e47ac9992
|
|
BLAKE2b-256 checksum How to use checksums |
1782204eaae693bf5c55c85879e055fbfe86941bccbe41e3d6d502319bb0a17d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / e2b_dockerfile_utils-0.1.0-py3-none-any.whl
| Download URL | e2b_dockerfile_utils-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fedc7d036d8a23cb962c01b90882ebec154520ec1bed064e1fe92796a7971553
|
|
BLAKE2b-256 checksum How to use checksums |
4ba32851fb65169f6724ac6befeb8f593e465ad4479d2a630d3b281ec36f73aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|