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.1
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.1.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| e2b_dockerfile_utils-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.7 kB
Release files / e2b_dockerfile_utils-0.1.1.tar.gz
| Download URL | e2b_dockerfile_utils-0.1.1.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c1d4179bae6f3131fe0bbb1e6787ffb07c6c6dca8bdb3399abb3de9056b2a08f
|
|
BLAKE2b-256 checksum How to use checksums |
5bfc15b2752ff08fcbb7c6b97451581e02dd189ddc9b6eb107bb17c35b04427f
|
| 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.1-py3-none-any.whl
| Download URL | e2b_dockerfile_utils-0.1.1-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c648ecf56b3ffdb6d91469580850f4691f019cb2c925405e776ad36b761204f1
|
|
BLAKE2b-256 checksum How to use checksums |
23398d3f59a073dd1637fccca4c921665935d9591cc1726b452f06ef7cdadabc
|
| 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}
|