Skip to content

Instantly share code, notes, and snippets.

@theronic
Created May 30, 2022 16:23
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theronic/084a1c24fef7eb2a89a711239116e54b to your computer and use it in GitHub Desktop.
Save theronic/084a1c24fef7eb2a89a711239116e54b to your computer and use it in GitHub Desktop.
Deploy Clojure to Fly.io: Efficient Multi-stage Docker build to Deploy Clojure Application to Fly.io
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 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