Skip to content

Generate Dockerfiles from Selmer templates#286

Merged
cap10morgan merged 1 commit into
masterfrom
refactor/dockerfile-templating
Jun 10, 2026
Merged

Generate Dockerfiles from Selmer templates#286
cap10morgan merged 1 commit into
masterfrom
refactor/dockerfile-templating

Conversation

@cap10morgan

Copy link
Copy Markdown
Collaborator

What

Replaces the hand-rolled string/vector concatenation in the Dockerfile generators with Selmer templates under resources/templates/:

  • Dockerfile.tmpl — outer skeleton (FROM, JDK copy, install section(s), entrypoint, CMD)
  • lein.tmpl / tools-deps.tmpl — the per-build-tool install sections

The templates read like real Dockerfiles: the install RUN commands live in them directly, with the distro-specific dependency lists looped in and dynamic values (checksums, the GPG signing key, the bundled clojure version) interpolated as Selmer placeholders. The build-tool namespaces shrink to just computing that context.

Why

The previous approach assembled Dockerfiles by concatenating vectors of strings and suffixing && \ line continuations, which made the shape of the generated file hard to follow. Moving the skeleton and commands into template files makes them legible at a glance.

Output changes

Identical to master for every image except the combined latest image, which loses a stray blank line between ENTRYPOINT and CMD so it matches the single-build-tool images:

 ENTRYPOINT ["entrypoint"]
-
 CMD ["-M", "--repl"]

Verified by regenerating every Dockerfile under both the babashka (bb run dockerfiles) and JVM (clojure -X:build-images) paths. bb test (12 tests, 51 assertions) and cljfmt check both pass.

Notes

  • Adds selmer/selmer to deps.edn for the JVM path; babashka bundles Selmer.
  • HTML escaping is turned off globally (Dockerfiles aren't HTML).
  • The bundled-clojure version for lein images (1.12.1) is now a named const instead of being hardcoded inline.

Replace the hand-rolled string/vector concatenation in the Dockerfile
generators with Selmer templates under resources/templates/:

- Dockerfile.tmpl  - the outer skeleton (FROM, JDK copy, install section(s),
                     entrypoint, CMD)
- lein.tmpl        - the leiningen install section
- tools-deps.tmpl  - the tools-deps install section

The templates read like real Dockerfiles: the install RUN commands live in
them directly, with the distro-specific dep lists looped in and dynamic
values (checksums, signing key, bundled clojure version) interpolated as
Selmer placeholders. The build-tool namespaces are reduced to computing that
context.

Output is identical to before for every image except the combined "latest"
image, which loses a stray blank line between ENTRYPOINT and CMD so it
matches the single-build-tool images. Verified by regenerating under both
babashka (bb run dockerfiles) and the JVM build-images path. bb test and
cljfmt pass.

Adds selmer/selmer to deps.edn for the JVM path; babashka bundles Selmer.

@Quantisan Quantisan left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense! Thanks!

@cap10morgan cap10morgan merged commit ba88af1 into master Jun 10, 2026
5 of 6 checks passed
@cap10morgan cap10morgan deleted the refactor/dockerfile-templating branch June 10, 2026 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants