I recently had to figure out for a Clojure application how to download all dependency JAR files, for use in a Docker container.
When creating an uberjar, depstar re-downloaded all the external dependencies from Maven central, even though in an earlier Docker build step, I ran clj -Spath
to pre-download them (presumably cached into the .m2 directory). In the past, I've used lein deps
to do something similiar.
I'm grateful for Sean Corfield helping out (again!!): In short, use clj -P
(short for "prepare") to download dependencies. Note the "A:depstar" option, which ensures that the depstar dependencies are downloaded, too.
Here's what it looks like in a Dockerfile:
# to pre-download dependencies, only done if deps.edn changes
RUN mkdir /tmp/pubsub-web
COPY ./pubsub-web/deps.edn /tmp/pubsub-web
WORKDIR /tmp/pubsub-web
RUN clj -P
RUN clj -A:depstar -P
Many thanks to @seancorfield for his help on Clojurians channel, and his work on
depstar
.He pointed me at this issue that would have helped: seancorfield/depstar#74
And the documentation for Clojure prepare flag ("-P"): https://clojure.org/reference/deps_and_cli#_prepare_for_execution
(think
lein deps
)