Deploy Clojure to Fly.io: Efficient Multi-stage Docker build to Deploy Clojure Application to Fly.io
This file contains 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-15-tools-deps AS builder | |
WORKDIR /opt | |
ADD deps.edn deps.edn | |
RUN clj -Sdeps '{:mvn/local-repo "./.m2/repository"}' -e "(prn \"Downloading deps\")" | |
RUN clj -e :ok | |
COPY . . | |
RUN clj -e :ok | |
RUN cd uberdeps && clojure -M -m "uberdeps.uberjar" --deps-file ../deps.edn --target /opt/app.jar | |
#------ Slim version ----- | |
FROM openjdk:15-slim-buster AS runtime | |
COPY --from=builder /opt/app.jar /app.jar | |
EXPOSE 8080 | |
ENV MALLOC_ARENA_MAX=2 | |
ENTRYPOINT ["java", "-cp", "app.jar", "clojure.main", "-m", "your.namespace.core"] |
This file contains 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
;; this goes in uberdeps/deps.edn (sorry gists do not allow subdirectories) | |
;; Note: distinct from your deps.edn file. | |
{:deps {uberdeps/uberdeps {:mvn/version "1.1.4"}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment