Fork me on GitHub
#tools-deps
<
2022-10-19
>
jasonjckn02:10:04

I’d like to do clj -P inside a dockerfile/docker build stage to cache all the maven dependencies, then clj -M at the entrypoint, but i’m concerned clj -Mwill still try to fetch dependencies over the network and error out and for various reasons I can only do network calls in docker build . is my concern warranted (?), if so is there a fix (other than producing uberjars).

seancorfield02:10:18

You might be able to use the -Scp option to pass it a pre-built classpath so it just uses what is specified without trying to download anything.

jasonjckn02:10:35

Ah yah, so -Spath and then java -cp … clojure.main -m xyz`` i’ll give it a shot

seancorfield02:10:07

Yeah, you could run bare java -cp with the saved result of -Spath. But clj itself has a -Scp option in case you need to run Clojure tools without recomputing/fetching anything.

👍 1
seancorfield02:10:32

(you mentioned clj -M so I figured you were trying to do something specific with :main-opts)

hiredman03:10:51

clj won't even run the process that has access to the code to fetch deps unless it hasn't computed the classpath for your deps.edn yet

hiredman03:10:15

Which is what -P is for

jasonjckn03:10:26

if i run -P, but then change the deps.edn it does a network call right

jasonjckn03:10:47

so that was the basis of my concern, you’re saying it won’t do a network call if deps.edn has the same content

hiredman03:10:05

Depends what you mean by same content, if the bytes hash the same (so whitespace and comments, etc count)

hiredman03:10:40

You need to make sure you are using the same set of aliases as well

👍 1
jasonjckn03:10:50

gotcha… well excellent, that’s what I was hoping for

Carsten Behring16:10:30

I was playing with something like that in the past. And I think there is no guaranty that clj does not "try" to access the network. The -P is more for "reducing download time" then to guarantee that no network call occur, I believe. Maybe worth to check with clojure.core team.

Wanja Hentze09:10:35

There are a few cases in which tools.deps will always hit the network, regardless of what is cached. The one we've ran into most often is https://clojure.atlassian.net/browse/TDEPS-223. That particular issue can be worked around by making all the git deps use full hashes and no tags.

Wanja Hentze09:10:57

Offline builds are not really a design goal I think, so you need a few tricks to make them work. Alternatively you can run a pre-populated git + maven caching proxy within your sandboxed build, but that's a bit more involved.