Avalable for work
Avalable for work
00
dfgen
CLI and menu-driven Bash utility that creates Dockerfiles from interactive selections or command-line flags. Validates inputs and produces build-ready Dockerfiles for repeatable image creation.
Problem
Creating Dockerfiles repeatedly is error-prone and slows container-based workflows, especially for developers who need consistent, best-practice images.
Solution
An interactive script that templates Dockerfile instructions, validates user input, and emits a ready-to-build Dockerfile or triggers an immediate docker build step.
Results / Impact
Reduced Dockerfile creation time and syntax errors. Enforced best-practice patterns across teams and increased reproducibility for local builds and CI pipelines.
Overview
Dfgen is a small, auditable Bash utility that guides users through Dockerfile generation. It supports both an interactive menu and a full CLI flag set. The goal: produce clean, minimal Dockerfiles that follow Docker best practices while requiring zero dependencies beyond standard Unix tools.
Quickstart
Clone and run:
git clone https://github.com/ousbaailyas/dfgen.git cd dfgen chmod +x dfgen ./dfgen # interactive ./dfgen -b ubuntu:22.04 -o myimage:latest -p 80,443 -e VAR=val
Generate and build in one step:
./dfgen -b ubuntu:20.04 -o myimage:latest # script writes Dockerfile then runs: docker build -t myimage:latest
Design goals
Simplicity: single-file Bash with clear functions and minimal branching.
Reproducibility: flag-driven mode creates identical Dockerfiles for CI and automation.
Validation: input checks for ports, env syntax, and common Docker mistakes.
Best practices: encourages small layers, explicit
USER,HEALTHCHECK, and non-root defaults.Auditable: generated Dockerfile is explicit and human-readable.
Features & supported instructions
Base image (
FROM) and optionalASstage.ARG,ENV,LABELandWORKDIR.COPY/ADD,RUN(optionally combined for fewer layers).EXPOSE(TCP/UDP),VOLUME,USER,ENTRYPOINTandCMD.HEALTHCHECKwith options.Shell selection and
SHELLoverride.Menu-driven flow and full flag-driven CLI for automation.
CLI examples
Interactive:
./dfgenFlag-driven:
./dfgen -b ubuntu:22.04 -o myapp:1.0 -e NODE_ENV=production,PORT=8080 \ -p 8080/tcp,9000/udp -u appuser:1000 -r "apt update && apt install -y curl" \ -c "./build" /app
Help:
./dfgen -hImplementation details
Input parsing: POSIX
getoptswrapper with canonicalization for multi-value flags (comma-separated).Validation routines: functions check
PORTformats (num[/tcp|/udp]),ENVpairs (KEY=VAL), and thatBASEis non-empty. Errors are surfaced with[ERR]and the script exits non-zero.Dockerfile composition: ordered generation to follow best practices:
FROM→ARG→LABEL→ENV→WORKDIR→COPY/ADD→RUN→EXPOSE→VOLUME→USER→HEALTHCHECK→ENTRYPOINT/CMD.Layer minimization: the generator can optionally collapse multiple
RUNcommands with&&and acleanupstep (apt clean / rm -rf /var/lib/apt/lists).Output modes:
--print(stdout),--file Dockerfile,--build(invokedocker build), and--dry-run(validate only).
Usage notes & examples
Create multi-stage build example via interactive prompts (select additional stage name and copy artifacts).
Healthcheck example:
--health 'CMD curl -f http://localhost:8080/healthz || exit 1' --health-interval 30s --health-timeout 5s --health-retries 3
Expose TCP and UDP:
-p 80,443/tcp,9000/udp
Edge cases & limitations
The script is a generator, not a linter — it validates formats but does not fully vet application-specific runtime correctness.
Non-standard Docker directives or engine-specific features (buildkit-only flags) are not supported out of the box.
Shell portability: requires Bash (for arrays and
/dev/tcpstyle features used elsewhere in the repo). Works on Linux/macOS where Bash is available.
Integration & workflows
Local dev: quick scaffolds for microservices and reproducible developer images.
CI: use flag-driven mode to produce consistent Dockerfiles inside CI templates before
docker build.Education: helpful for teams less experienced with Dockerfile best practices — the menu enforces a small checklist.
Example CI snippet:
./dfgen -b python:3.11-slim -e PYTHONUNBUFFERED=1 -w /app -c ./src /app -o ci-image:latest docker build -t ci-image:
Testing & validation
Unit-check flag parsing with edge cases (empty env values, malformed ports).
Generate Dockerfiles and run
docker build --no-cachein ephemeral runners to ensure generated files are buildable.Confirm healthcheck syntax and user switching by running lightweight containers.
Extension ideas
JSON/YAML manifest mode for programmatic generation.
Templates for common stacks (node, python, go, nginx) selectable via menu.
Linter integration (hadolint) to optionally validate generated Dockerfile.
Support buildkit syntax and
--platformmulti-arch templates.
Best practices
Prefer explicit
USERand non-root runtime.Group
RUNcommands and clean package caches to minimize layer size.Pin base image versions when reproducibility matters.
Review generated Dockerfile before automated builds in sensitive environments.
Contribution & maintainers
Keep PRs focused: new template, validation rule, or bug fix.
Add unit tests for parsing helpers when extending CLI flags.
License & ethics
MIT License. Use responsibly.
Technical Skills: automation, tooling, Bash scripting, Dockerfile authoring, CI integration
Soft Skills: reproducibility, clarity, minimal design, developer ergonomics
Overview
Dfgen is a small, auditable Bash utility that guides users through Dockerfile generation. It supports both an interactive menu and a full CLI flag set. The goal: produce clean, minimal Dockerfiles that follow Docker best practices while requiring zero dependencies beyond standard Unix tools.
Quickstart
Clone and run:
git clone https://github.com/ousbaailyas/dfgen.git cd dfgen chmod +x dfgen ./dfgen # interactive ./dfgen -b ubuntu:22.04 -o myimage:latest -p 80,443 -e VAR=val
Generate and build in one step:
./dfgen -b ubuntu:20.04 -o myimage:latest # script writes Dockerfile then runs: docker build -t myimage:latest
Design goals
Simplicity: single-file Bash with clear functions and minimal branching.
Reproducibility: flag-driven mode creates identical Dockerfiles for CI and automation.
Validation: input checks for ports, env syntax, and common Docker mistakes.
Best practices: encourages small layers, explicit
USER,HEALTHCHECK, and non-root defaults.Auditable: generated Dockerfile is explicit and human-readable.
Features & supported instructions
Base image (
FROM) and optionalASstage.ARG,ENV,LABELandWORKDIR.COPY/ADD,RUN(optionally combined for fewer layers).EXPOSE(TCP/UDP),VOLUME,USER,ENTRYPOINTandCMD.HEALTHCHECKwith options.Shell selection and
SHELLoverride.Menu-driven flow and full flag-driven CLI for automation.
CLI examples
Interactive:
./dfgenFlag-driven:
./dfgen -b ubuntu:22.04 -o myapp:1.0 -e NODE_ENV=production,PORT=8080 \ -p 8080/tcp,9000/udp -u appuser:1000 -r "apt update && apt install -y curl" \ -c "./build" /app
Help:
./dfgen -hImplementation details
Input parsing: POSIX
getoptswrapper with canonicalization for multi-value flags (comma-separated).Validation routines: functions check
PORTformats (num[/tcp|/udp]),ENVpairs (KEY=VAL), and thatBASEis non-empty. Errors are surfaced with[ERR]and the script exits non-zero.Dockerfile composition: ordered generation to follow best practices:
FROM→ARG→LABEL→ENV→WORKDIR→COPY/ADD→RUN→EXPOSE→VOLUME→USER→HEALTHCHECK→ENTRYPOINT/CMD.Layer minimization: the generator can optionally collapse multiple
RUNcommands with&&and acleanupstep (apt clean / rm -rf /var/lib/apt/lists).Output modes:
--print(stdout),--file Dockerfile,--build(invokedocker build), and--dry-run(validate only).
Usage notes & examples
Create multi-stage build example via interactive prompts (select additional stage name and copy artifacts).
Healthcheck example:
--health 'CMD curl -f http://localhost:8080/healthz || exit 1' --health-interval 30s --health-timeout 5s --health-retries 3
Expose TCP and UDP:
-p 80,443/tcp,9000/udp
Edge cases & limitations
The script is a generator, not a linter — it validates formats but does not fully vet application-specific runtime correctness.
Non-standard Docker directives or engine-specific features (buildkit-only flags) are not supported out of the box.
Shell portability: requires Bash (for arrays and
/dev/tcpstyle features used elsewhere in the repo). Works on Linux/macOS where Bash is available.
Integration & workflows
Local dev: quick scaffolds for microservices and reproducible developer images.
CI: use flag-driven mode to produce consistent Dockerfiles inside CI templates before
docker build.Education: helpful for teams less experienced with Dockerfile best practices — the menu enforces a small checklist.
Example CI snippet:
./dfgen -b python:3.11-slim -e PYTHONUNBUFFERED=1 -w /app -c ./src /app -o ci-image:latest docker build -t ci-image:
Testing & validation
Unit-check flag parsing with edge cases (empty env values, malformed ports).
Generate Dockerfiles and run
docker build --no-cachein ephemeral runners to ensure generated files are buildable.Confirm healthcheck syntax and user switching by running lightweight containers.
Extension ideas
JSON/YAML manifest mode for programmatic generation.
Templates for common stacks (node, python, go, nginx) selectable via menu.
Linter integration (hadolint) to optionally validate generated Dockerfile.
Support buildkit syntax and
--platformmulti-arch templates.
Best practices
Prefer explicit
USERand non-root runtime.Group
RUNcommands and clean package caches to minimize layer size.Pin base image versions when reproducibility matters.
Review generated Dockerfile before automated builds in sensitive environments.
Contribution & maintainers
Keep PRs focused: new template, validation rule, or bug fix.
Add unit tests for parsing helpers when extending CLI flags.
License & ethics
MIT License. Use responsibly.
Technical Skills: automation, tooling, Bash scripting, Dockerfile authoring, CI integration
Soft Skills: reproducibility, clarity, minimal design, developer ergonomics
Overview
Dfgen is a small, auditable Bash utility that guides users through Dockerfile generation. It supports both an interactive menu and a full CLI flag set. The goal: produce clean, minimal Dockerfiles that follow Docker best practices while requiring zero dependencies beyond standard Unix tools.
Quickstart
Clone and run:
git clone https://github.com/ousbaailyas/dfgen.git cd dfgen chmod +x dfgen ./dfgen # interactive ./dfgen -b ubuntu:22.04 -o myimage:latest -p 80,443 -e VAR=val
Generate and build in one step:
./dfgen -b ubuntu:20.04 -o myimage:latest # script writes Dockerfile then runs: docker build -t myimage:latest
Design goals
Simplicity: single-file Bash with clear functions and minimal branching.
Reproducibility: flag-driven mode creates identical Dockerfiles for CI and automation.
Validation: input checks for ports, env syntax, and common Docker mistakes.
Best practices: encourages small layers, explicit
USER,HEALTHCHECK, and non-root defaults.Auditable: generated Dockerfile is explicit and human-readable.
Features & supported instructions
Base image (
FROM) and optionalASstage.ARG,ENV,LABELandWORKDIR.COPY/ADD,RUN(optionally combined for fewer layers).EXPOSE(TCP/UDP),VOLUME,USER,ENTRYPOINTandCMD.HEALTHCHECKwith options.Shell selection and
SHELLoverride.Menu-driven flow and full flag-driven CLI for automation.
CLI examples
Interactive:
./dfgenFlag-driven:
./dfgen -b ubuntu:22.04 -o myapp:1.0 -e NODE_ENV=production,PORT=8080 \ -p 8080/tcp,9000/udp -u appuser:1000 -r "apt update && apt install -y curl" \ -c "./build" /app
Help:
./dfgen -hImplementation details
Input parsing: POSIX
getoptswrapper with canonicalization for multi-value flags (comma-separated).Validation routines: functions check
PORTformats (num[/tcp|/udp]),ENVpairs (KEY=VAL), and thatBASEis non-empty. Errors are surfaced with[ERR]and the script exits non-zero.Dockerfile composition: ordered generation to follow best practices:
FROM→ARG→LABEL→ENV→WORKDIR→COPY/ADD→RUN→EXPOSE→VOLUME→USER→HEALTHCHECK→ENTRYPOINT/CMD.Layer minimization: the generator can optionally collapse multiple
RUNcommands with&&and acleanupstep (apt clean / rm -rf /var/lib/apt/lists).Output modes:
--print(stdout),--file Dockerfile,--build(invokedocker build), and--dry-run(validate only).
Usage notes & examples
Create multi-stage build example via interactive prompts (select additional stage name and copy artifacts).
Healthcheck example:
--health 'CMD curl -f http://localhost:8080/healthz || exit 1' --health-interval 30s --health-timeout 5s --health-retries 3
Expose TCP and UDP:
-p 80,443/tcp,9000/udp
Edge cases & limitations
The script is a generator, not a linter — it validates formats but does not fully vet application-specific runtime correctness.
Non-standard Docker directives or engine-specific features (buildkit-only flags) are not supported out of the box.
Shell portability: requires Bash (for arrays and
/dev/tcpstyle features used elsewhere in the repo). Works on Linux/macOS where Bash is available.
Integration & workflows
Local dev: quick scaffolds for microservices and reproducible developer images.
CI: use flag-driven mode to produce consistent Dockerfiles inside CI templates before
docker build.Education: helpful for teams less experienced with Dockerfile best practices — the menu enforces a small checklist.
Example CI snippet:
./dfgen -b python:3.11-slim -e PYTHONUNBUFFERED=1 -w /app -c ./src /app -o ci-image:latest docker build -t ci-image:
Testing & validation
Unit-check flag parsing with edge cases (empty env values, malformed ports).
Generate Dockerfiles and run
docker build --no-cachein ephemeral runners to ensure generated files are buildable.Confirm healthcheck syntax and user switching by running lightweight containers.
Extension ideas
JSON/YAML manifest mode for programmatic generation.
Templates for common stacks (node, python, go, nginx) selectable via menu.
Linter integration (hadolint) to optionally validate generated Dockerfile.
Support buildkit syntax and
--platformmulti-arch templates.
Best practices
Prefer explicit
USERand non-root runtime.Group
RUNcommands and clean package caches to minimize layer size.Pin base image versions when reproducibility matters.
Review generated Dockerfile before automated builds in sensitive environments.
Contribution & maintainers
Keep PRs focused: new template, validation rule, or bug fix.
Add unit tests for parsing helpers when extending CLI flags.
License & ethics
MIT License. Use responsibly.
Technical Skills: automation, tooling, Bash scripting, Dockerfile authoring, CI integration
Soft Skills: reproducibility, clarity, minimal design, developer ergonomics
Overview
Dfgen is a small, auditable Bash utility that guides users through Dockerfile generation. It supports both an interactive menu and a full CLI flag set. The goal: produce clean, minimal Dockerfiles that follow Docker best practices while requiring zero dependencies beyond standard Unix tools.
Quickstart
Clone and run:
git clone https://github.com/ousbaailyas/dfgen.git cd dfgen chmod +x dfgen ./dfgen # interactive ./dfgen -b ubuntu:22.04 -o myimage:latest -p 80,443 -e VAR=val
Generate and build in one step:
./dfgen -b ubuntu:20.04 -o myimage:latest # script writes Dockerfile then runs: docker build -t myimage:latest
Design goals
Simplicity: single-file Bash with clear functions and minimal branching.
Reproducibility: flag-driven mode creates identical Dockerfiles for CI and automation.
Validation: input checks for ports, env syntax, and common Docker mistakes.
Best practices: encourages small layers, explicit
USER,HEALTHCHECK, and non-root defaults.Auditable: generated Dockerfile is explicit and human-readable.
Features & supported instructions
Base image (
FROM) and optionalASstage.ARG,ENV,LABELandWORKDIR.COPY/ADD,RUN(optionally combined for fewer layers).EXPOSE(TCP/UDP),VOLUME,USER,ENTRYPOINTandCMD.HEALTHCHECKwith options.Shell selection and
SHELLoverride.Menu-driven flow and full flag-driven CLI for automation.
CLI examples
Interactive:
./dfgenFlag-driven:
./dfgen -b ubuntu:22.04 -o myapp:1.0 -e NODE_ENV=production,PORT=8080 \ -p 8080/tcp,9000/udp -u appuser:1000 -r "apt update && apt install -y curl" \ -c "./build" /app
Help:
./dfgen -hImplementation details
Input parsing: POSIX
getoptswrapper with canonicalization for multi-value flags (comma-separated).Validation routines: functions check
PORTformats (num[/tcp|/udp]),ENVpairs (KEY=VAL), and thatBASEis non-empty. Errors are surfaced with[ERR]and the script exits non-zero.Dockerfile composition: ordered generation to follow best practices:
FROM→ARG→LABEL→ENV→WORKDIR→COPY/ADD→RUN→EXPOSE→VOLUME→USER→HEALTHCHECK→ENTRYPOINT/CMD.Layer minimization: the generator can optionally collapse multiple
RUNcommands with&&and acleanupstep (apt clean / rm -rf /var/lib/apt/lists).Output modes:
--print(stdout),--file Dockerfile,--build(invokedocker build), and--dry-run(validate only).
Usage notes & examples
Create multi-stage build example via interactive prompts (select additional stage name and copy artifacts).
Healthcheck example:
--health 'CMD curl -f http://localhost:8080/healthz || exit 1' --health-interval 30s --health-timeout 5s --health-retries 3
Expose TCP and UDP:
-p 80,443/tcp,9000/udp
Edge cases & limitations
The script is a generator, not a linter — it validates formats but does not fully vet application-specific runtime correctness.
Non-standard Docker directives or engine-specific features (buildkit-only flags) are not supported out of the box.
Shell portability: requires Bash (for arrays and
/dev/tcpstyle features used elsewhere in the repo). Works on Linux/macOS where Bash is available.
Integration & workflows
Local dev: quick scaffolds for microservices and reproducible developer images.
CI: use flag-driven mode to produce consistent Dockerfiles inside CI templates before
docker build.Education: helpful for teams less experienced with Dockerfile best practices — the menu enforces a small checklist.
Example CI snippet:
./dfgen -b python:3.11-slim -e PYTHONUNBUFFERED=1 -w /app -c ./src /app -o ci-image:latest docker build -t ci-image:
Testing & validation
Unit-check flag parsing with edge cases (empty env values, malformed ports).
Generate Dockerfiles and run
docker build --no-cachein ephemeral runners to ensure generated files are buildable.Confirm healthcheck syntax and user switching by running lightweight containers.
Extension ideas
JSON/YAML manifest mode for programmatic generation.
Templates for common stacks (node, python, go, nginx) selectable via menu.
Linter integration (hadolint) to optionally validate generated Dockerfile.
Support buildkit syntax and
--platformmulti-arch templates.
Best practices
Prefer explicit
USERand non-root runtime.Group
RUNcommands and clean package caches to minimize layer size.Pin base image versions when reproducibility matters.
Review generated Dockerfile before automated builds in sensitive environments.
Contribution & maintainers
Keep PRs focused: new template, validation rule, or bug fix.
Add unit tests for parsing helpers when extending CLI flags.
License & ethics
MIT License. Use responsibly.
Technical Skills: automation, tooling, Bash scripting, Dockerfile authoring, CI integration
Soft Skills: reproducibility, clarity, minimal design, developer ergonomics
category
value
category
value
category
value
category
value
[INF]
ping