Skip to content

Instantly share code, notes, and snippets.

@cellularmitosis cellularmitosis/README.md
Last active Oct 15, 2019

Embed
What would you like to do?
Simple Clojure "Hello world" using leiningen

Blog 2019/7/17

<- previous | index | next ->

Simple Clojure "Hello world" using leiningen

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.

Dockerfile

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"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.