Fork me on GitHub
#practicalli
<
2022-10-31
>
practicalli-johnny08:10:03

A quick article on how I am uhttps://practical.li/blog/posts/build-and-run-clojure-with-multistage-dockerfile/. I use this approach mostly for the continuous integration pipeline, although I am using docker compose for local testing with the relational database the current company I work for uses https://practical.li/blog/posts/build-and-run-clojure-with-multistage-dockerfile/ If you have any suggestions or improvements to tweak the Dockerfile, please share them (I am considering if there are any commands I want to string together with && to reduce the number of layers. I want to balance this with maximising the docker cache and keeping the Dockerfile pleasant to work with 🙂

👏 2
iarenaza08:10:19

One thing you can do in many (most?) cases is to use the JRE variant of Eclipse Temurin images, for the containers that are finally run. Those images don't need the full JDK at all, just the JRE subset. You shave several dozen megabytes from the final image 😁

practicalli-johnny10:10:40

I did initially consider using a JRE to save even more space (thinking about that since Java 9 though). The Eclipse-temurin readme recommends building the JRE image and I’d probably feel compelled to figure out how to optimise that with module choice or be paranoid I missed something 🙂 I could use 17-jre-alpine although then I am using a (slightly) different image to run the service to that which was used to build it, as the Clojure image uses 17-jdk-alpine . I’ll add using a JRE to my todo list and do some testing. Thanks.

lread13:10:21

This is really helpful @U05254DQM, thanks! I'll likely apply at least some of the knowledge you shared to cljdoc's somewhat neglected Dockerfile.

👍 1
practicalli-johnny14:10:24

To use a Java Run-time Environment (JRE) rather than the full JDK, then I could use a Multi-stage docker file like this https://gist.github.com/practicalli-john/84c8900d95fe3729c5ccd17ef3b26bb4 (although I havent tried it yet 🙂