docker-dsl
An imperative, context-manager-based Python DSL for authoring multi-stage
Dockerfiles. Write builds with with blocks, conditionals, comprehensions, and
reusable helpers, then render one recipe into many Dockerfile variants.
Install
Run it through uvx, no install needed:
uvx docker-dsl --help
Quickstart
Write a recipe module, minimal.py:
from docker_dsl import Stage
from docker_dsl import context as ctx
ctx.register("tag", str)
with Stage("ubuntu:24.04") as s:
s.arg("APP_TAG", ctx.tag or "latest", env=True)
s.workdir("/app")
with s.run() as r:
r.echo("hello from docker-dsl") > "/app/greeting.txt"
s.cmd("cat", "/app/greeting.txt")
Render it:
uvx docker-dsl minimal --tag=v1.0.0 --out Dockerfile
Dockerfile now holds:
# syntax=docker/dockerfile:1
FROM ubuntu:24.04 AS base
ARG APP_TAG=v1.0.0
ENV APP_TAG=${APP_TAG}
WORKDIR /app
RUN echo "hello from docker-dsl" > /app/greeting.txt
CMD ["cat", "/app/greeting.txt"]
Change --tag and render again for a different Dockerfile from the same recipe.
Why
RUNchains glued with&&are fragile. The run builder accumulates commands in Python and emits one correctRUN, withcdscoping restored for you.- Variants drift apart. One recipe takes
--gpu=true|falseand renders both a GPU and a CPU image from the same code path, instead of two Dockerfiles that diverge over time. - BuildKit mounts are easy to get wrong.
cache,secret, andbindare scoped context managers, so everyRUNinside the block picks them up and nothing leaks out.
Docs
The documentation has a tutorial, task-focused guides (multi-stage builds, mounts, smart apt, the run builder, reusable helpers, and the CLI), and the full API reference.
License
This project is licensed under the MIT License; see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docker_dsl-0.1.1.tar.gz.
File metadata
- Download URL: docker_dsl-0.1.1.tar.gz
- Upload date:
- Size: 58.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32cd52585f63d547df250f21b14588ee56cbb5be7ad6db7d2c0b43c08261c3fa
|
|
| MD5 |
981623e79fafebd833076fef0b3d1e13
|
|
| BLAKE2b-256 |
f358905b68e58d13669e102bd27885c9cc815402a85ca77dd60282ca8033c2f9
|
Provenance
The following attestation bundles were made for docker_dsl-0.1.1.tar.gz:
Publisher:
release-pypi.yml on yasyf/docker-dsl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docker_dsl-0.1.1.tar.gz -
Subject digest:
32cd52585f63d547df250f21b14588ee56cbb5be7ad6db7d2c0b43c08261c3fa - Sigstore transparency entry: 2044276664
- Sigstore integration time:
-
Permalink:
yasyf/docker-dsl@235467e3bfec31c2eb0b35e3c9707b55854ffd3c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/yasyf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@235467e3bfec31c2eb0b35e3c9707b55854ffd3c -
Trigger Event:
push
-
Statement type:
File details
Details for the file docker_dsl-0.1.1-py3-none-any.whl.
File metadata
- Download URL: docker_dsl-0.1.1-py3-none-any.whl
- Upload date:
- Size: 62.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4750aa5479aadc219a45487dc6881dc6819231492ca83f729694760d245f8c89
|
|
| MD5 |
56980f258d51e065df53133b7d4b9089
|
|
| BLAKE2b-256 |
258cee471f5fd25d3d63b97c9280e8424de8a1a34f7adb956743c3d158393293
|
Provenance
The following attestation bundles were made for docker_dsl-0.1.1-py3-none-any.whl:
Publisher:
release-pypi.yml on yasyf/docker-dsl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docker_dsl-0.1.1-py3-none-any.whl -
Subject digest:
4750aa5479aadc219a45487dc6881dc6819231492ca83f729694760d245f8c89 - Sigstore transparency entry: 2044276676
- Sigstore integration time:
-
Permalink:
yasyf/docker-dsl@235467e3bfec31c2eb0b35e3c9707b55854ffd3c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/yasyf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@235467e3bfec31c2eb0b35e3c9707b55854ffd3c -
Trigger Event:
push
-
Statement type: