Is there an easy way to figure out which deps.edn files inside a project will be used when clj -P -M:whatever is run?
Would be useful when creating OCI images so that the layer that has all the deps doesn’t get changed on every .clj change.
clj -Sdescribe shows which files are used.
It doesn’t seem to list any of the files from under :local/root.
Oh, you mean where the dependencies come from? No, I don’t think there’s any way to derive that.
I guess -X:deps tree :aliases '[:whatever]' might get you closer?
clojure -X:deps tree :aliases '[:whatever]' | fgrep ' /'
Since :local/root is resolved to an absolute path, that should match and give you a list of folders to search for deps.edn file.Oof, yeah. Not as ergonomic as one might’ve hoped, but I suppose it’ll do. Thanks!
Ah crap, it’s all for naught anyway. COPY can’t accept non-static lists in any way, and running clojure at that stage would download POM files that I’m downloading later anyway with -P.
So I’ll probably settle on just copying every single deps.edn in the project.
Ah… logistics… 😉
Maybe a silly question, but why do you need the deps.edn for that? Pack already puts libs in a separate layer btw: https://github.com/dkarvik/pack/blob/480508719a3233df3526e5145cecd1894850412c/src/io/dominic/pack/jib.clj not sure if it can serve as inspiration? It uses the basis rather than bash scripting together.
> why do you need the deps.edn for that?
I prefer to use clojure -P inside a container with the same exact environment that will be used when the app actually runs.
I see. But you want to copy in the deps.edn files in layers for reproducibility, then run clojure before you copy in the app code? Seems like you almost want to do something outside the container (to locate the basis files you want) then -P inside?
I can copy everything into a separate container and extract just deps.edn files from it into one of the layers in the “main chain” of containers. So a change to .clj won’t invalidate the layer with all the deps.
Is that called a build container in docker terminology? Or something else?
Eh, maybe. I don’t use all that machinery often enough to remember terminology, and I don’t use Docker at all. :)
Dare I ask what you're using?
Podman.
Which builder for it?
I don’t even know what the question means, to be honest. :D
I have a somewhat complex Containerfile and I run podman build when needed.
Ah, I didn't know they'd added Dockerfile compat. Once upon a time you used buildah or other third party tools for podman. What is the Containerfile feature you use to run a layer in another image to generate what you need?
Interesting, I’ve been using Podman that way for more than 4 years.
I just have FROM something AS label where something gets made, and then under some other FROM something AS other_label I do COPY --from=label /src /dst.
My view is way way out of date 🙂 I don't keep a close eye on these things. Ah, I never wrapped my head around that trick. I'll have to go have another read!
I remember having to spend a whole work day to get everything working the way I wanted it to (well, at least at that point in time - now greedy me wants even more). Since the app is not just a Clojure web app, it also needs somewhat large data files, Ubuntu libraries and executables, and custom-built stuff. And it all has to fit under 1 GB to be deployable on Heroku.
But in the end it turned out to be quite simple. The worst bits are just cleaning up after apt to remove in a non-compliant way stuff that I don’t need. At some point the app also needed Python, and I even had to straight up rm -rf some Python bits that I wasn’t using, just because they were taking way too much space.
Ubuntu libraries is a shame, otherwise I'd recommend the Google teenytiny containers. They're very good.
> And it all has to fit under 1 GB to be deployable on Heroku. Oh, apparently it’s the case for “slugs” (deployment via Heroku buildpacks) but not for images. And it can’t matter anyway because of the overlay file system. Alright, it’ll let me clean up Containerfile quite a bit.