Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
M. H. Neifer
M. H. Neifer
@howlingmad@howlingmad.vivaldi.net  ·  activity timestamp 5 days ago

I finally found some time to play with Lisp again. I always wanted to try Clojure, but I don’t like the available online editors very much. While their functionality has increased dramatically over the recent years, you need a stable Internet connection to use them and you never really know what happens with the source code you save online on some cloud servers. I prefer offline IDEs. Or at least an offline REPL.

As Clojure runs on the JVM, this means installing a JRE. Generally, I avoid installing additional software. Most of the time, you can’t un-install cleanly and your OS gets dirty over time. Windows is especially vulnerable to this. Maybe Docker can help here. Let’s give it a try and write a Dockerfile to set-up a Clojure REPL. There are several ready-to-use Docker images for Java available. You can choose your favorite JDK and OS. Have a look at the (deprecated) OpenJDK image to see some examples. Let’s use the Eclipse Temurin JDK 21 with Ubuntu for now. This means that the Dockerfile starts as follows.

FROM eclipse-temurin:21-noble

After you have selected your JDK / OS base image, you might have to install some Clojure dependencies. The eclipse-temurin:21-noble image is based on Ubuntu 24. As I found out, with this combination, one needs to install the rlwrap package to be able to use the Clojure command-line REPL. Therefore, we need to install rlwrap with apt. We can use the RUN instruction to run apt during image build. Let’s add the instruction to the Dockerfile to update apt sources and install rlwrap.

FROM eclipse-temurin:21-nobleRUN apt update && apt install -y rlwrap

After you have installed the Clojure dependencies, you can finally install Clojure itself. As we have a standard Linux base image, we can just use the Linux installation commands given on the Clojure installation website. They curl an install script and then execute the script. We will add RUN instructions for all commands given so the Dockerfile looks as follows now.

FROM eclipse-temurin:21-nobleRUN apt update && apt install -y rlwrapRUN curl -L -O https://github.com/clojure/brew-install/releases/latest/download/linux-install.shRUN chmod +x linux-install.shRUN ./linux-install.sh

Now we have an image with Clojure installed. That’s nice, but what we really want is a ready-to-use REPL. Clojure provides the clj command to start a REPL. We can use the CMD instruction to set the command to be executed when running a container from the build image. After adding the CMD instruction, our Dockerfile is now complete.

FROM eclipse-temurin:21-nobleRUN apt update && apt install -y rlwrapRUN curl -L -O https://github.com/clojure/brew-install/releases/latest/download/linux-install.shRUN chmod +x linux-install.shRUN ./linux-install.shCMD ["clj"]

You have to execute the docker build and docker run commands to build an image from this Dockerfile and then run a container based on the build image. Hopefully I will find enough free time to play around with this container REPL to see how usable this approach is. And maybe write another blog entry about my experience.

https://howlingmad.vivaldi.net/2025/12/26/setting-up-a-clojure-development-environment/

#clojure #docker #lisp

Clojure

  • Copy link
  • Flag this post
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.1-alpha.41 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct