Last active
April 21, 2019 11:29
-
-
Save snorremd/9db3e0891368ae597353bf91e7c317ae to your computer and use it in GitHub Desktop.
Clojure tools.deps multi-stage Dockerfile setup to compile Clojure code inside Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM clojure:openjdk-11-tools-deps-1.10.0.442 as builder | |
WORKDIR /app | |
# Install deps | |
COPY ./deps.edn ./ | |
RUN clojure -Abuild -e "(clojure-version)" | |
# Compile Clojure code | |
ADD . /app | |
RUN clojure -Abuild | |
FROM openjdk:11.0.2-slim | |
COPY --from=builder /app/target/lib/lib /app/lib | |
COPY --from=builder /app/target/classes /app/classes | |
WORKDIR /app | |
CMD java $JAVA_OPTS -cp "classes:lib/*" our-app.core |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The builder stage tries to be smart about copying only the deps.edn file and executing a simple Clojure script
(clojure-version)
to get the dependencies. Only then does it copy over application files and start the actual build. This should help with caching.