Blog 2019/7/17
<- previous | index | next ->
Create a new single-file Clojure project using the main template (thanks to Ming Pan):
$ lein new main hello
$ cd hello
Run it:
$ lein run
Or start a REPL:
$ lein repl
and then execute the main function by typing (-main)
into the REPL.
You can also create a simple Dockerfile:
FROM clojure
COPY . /root
WORKDIR /root
CMD ["lein", "run"]
Build it:
$ docker build -t hello .
Run it:
$ docker run hello
You can speed this up a bit by generating an uberjar (thanks to Divyum Rastogi):
FROM clojure
COPY . /root
WORKDIR /root
RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar
CMD ["java", "-jar", "app-standalone.jar"]