This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-03
Channels
- # adventofcode (107)
- # announcements (1)
- # asami (14)
- # babashka (67)
- # beginners (89)
- # calva (34)
- # cider (17)
- # clj-kondo (5)
- # cljs-dev (2)
- # clojure (57)
- # clojure-europe (52)
- # clojure-india (1)
- # clojure-italy (1)
- # clojure-losangeles (2)
- # clojure-nl (6)
- # clojure-uk (39)
- # clojurescript (40)
- # community-development (3)
- # conjure (3)
- # cursive (17)
- # datomic (11)
- # docker (13)
- # events (3)
- # figwheel-main (3)
- # fulcro (12)
- # graalvm (7)
- # holy-lambda (7)
- # honeysql (9)
- # introduce-yourself (5)
- # malli (9)
- # minecraft (3)
- # missionary (21)
- # nextjournal (7)
- # off-topic (52)
- # pathom (3)
- # polylith (11)
- # portal (3)
- # re-frame (21)
- # reagent (34)
- # reclojure (7)
- # reitit (1)
- # reveal (11)
- # shadow-cljs (68)
- # tools-build (12)
- # tools-deps (5)
- # vim (4)
- # xtdb (9)
Is there a good way to copy all of the dependencies to run a thin jar to a directory using the basis?
The usecase here is setting up a dockerfile layer to contain all the dependencies for a jar produced from a polylith monorepo, so that in the final dockerfile will contain only the thin jar and its dependencies, and Docker will be able to cache all the dependencies between runs, but ideally without relying on just caching the .m2 directory and putting the entire monorepo into the image, because that will get large.
Fwiw, this is exactly how pack works out of the box! It's not tools.build compatible yet though (working on it!). We create the lib layers first, then the application layers.
It has been a while since I have thought about docker, but I don't believe having a thin jar vs an uberjar will improve Dockers caching between builds
I've been told that in theory if only the thin jar has changed and the final docker image contains nothing but the dependencies and the thin jar, it should be able to cache the dependencies. If that's not the case then I can just move on with the uberjar.
https://github.com/clojure/tools.deps.alpha/blob/master/src/main/clojure/clojure/tools/deps/alpha.clj#L793 classpath-roots is what you want from the basis
and unless you specifically remove them from the deps information you calculate the basis from, it will include your source directories as well
it might be a good idea to pre-generate a file that contains the classpath as well, so you can easily launch with something like java -cp $(cat classpath-file) your.main.Class
it is tempting to use java -cp whatever/* your.main.Class
but using the globing might not put things on the classpath in the same order as tools.deps does
Alright, thanks!