r/Clojure • • Jan 23 '26

clj-pack — Package Clojure apps into self-contained binaries without GraalVM

I built a tool to solve a problem I kept hitting: deploying Clojure apps without requiring Java on the target machine.23:20:00 [3/101]

The usual answer is GraalVM native-image, but in practice it means dealing with reflection configs, library incompatibilities, long build times, and a complex toolchain. For many projects it's more friction than it's worth.

clj-pack takes a different approach: it bundles a minimal JVM runtime (via jlink) with your uberjar into a single executable. The result is a binary that runs anywhere with zero external dependencies and full JVM compatibility — no reflection configs, no unsupported libraries, your app runs exactly as it does in development.

clj-pack build --input ./my-project --output ./dist/my-app
./dist/my-app  # no Java needed

How it works:

  • Detects your build system (deps.edn or project.clj)
  • Compiles the uberjar
  • Downloads a JDK from Adoptium (cached locally)
  • Uses jdeps + jlink to create a minimal runtime (~30-50 MB)
  • Packs everything into a single binary

The binary extracts on first run (cached by content hash), subsequent runs are instant.

Trade-off is honest: binaries are slightly larger than GraalVM output (~30-50 MB vs ~20-40 MB), and first execution has extraction overhead. But you get full compatibility and a simple build process in return.

Written in Rust, supports Linux and macOS (x64/aarch64).

https://github.com/avelino/clj-pack

Feedback and contributions welcome

71 Upvotes

17 comments sorted by

View all comments

Show parent comment

2

u/SmartLow8757 Jan 23 '26

>  But since the binary basically "packs" a full JVM and unzips it on first usage, wouldn't it be better if we could re-use the existing JVMs people already have?

what I'm aiming for with the project is to avoid depending on a JVM environment for you; I'm thinking about production, not a development environment
I want to have a Docker image "with nothing" and the binary inside, keeping the Docker image distribution "small"

5

u/Borkdude Jan 23 '26

If you are thinking about production, unzipping on first usage probably isn't optimal for startup speed. So it depends on what kind of production you are targeting.