This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # babashka (1)
- # babashka-sci-dev (27)
- # beginners (13)
- # cljdoc (1)
- # clojure (24)
- # clojure-austin (1)
- # clojurescript (76)
- # data-science (18)
- # datomic (7)
- # java (2)
- # malli (7)
- # nbb (7)
- # off-topic (34)
- # portal (1)
- # reagent (9)
- # reitit (4)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (11)
- # squint (7)
- # tools-build (7)
- # uncomplicate (1)
Hi 👋 ! So far I never needed to compile my application, but now I would like to compile it ahead-of-time (mainly to Dockerize it).
I have followed the instructions in the tools.build docs to setup a
build.clj and the appropriate steps to assemble an uber-jar.
I was a bit surprised by the fact that def statements are actually executed during the compilation, but that’s just how it works right? I get this by now.
But, my question that I could not answer by researching so far is, how to work around it?
I just have a couple of defs, e.g. to have an atom holding the database connection and another one for some Compojure routes and similar.
It cannot really be best practice to require having a database server ready during compilation or can it?
So you can either have some function that creates the server and passes it on, or initializes the atom, or use something like wrapping it in a delay and deref on use (so it’s not immediately created)
> would like to compile it ahead-of-time (mainly to Dockerize it). Want to push back on this a bit and say that compiling the clj files to class files into the uberjar is not necessary. And I don't see how a container would change this in any way
I find AOT compilation useful, especially in terms of startup performance. It is not necessary but a default choice for all our production apps
> So you can either have some function that creates the server and passes it on, or initializes the atom Thanks a lot! That worked out relatively smooth.
> compiling the clj files to class files into the uberjar is not necessary. And I don’t see how a container would change this in any way Sorry, this was not well formulated. I also used depstar before and it did not compile aot. I think I was under the impression it’s necessary with tools.build. But probably not even that, I just did not find an example how to do it. Thanks for the advice.