The Dockerfile
in this repository allows building an OCI image usable as a portable development environment based on the official Clojure image tagged tools-deps-bookworm
.
The produced image contains, apart from the Clojure CLI, the following manually added utilities:
-
Prelude configuration for Emacs
-
CIDER for Clojure development in Emacs (because, somehow, Prelude does not install it by default, contrary to what is written in its docs)
-
Local mirrors of the following package archives for Emacs:
maintained by d12frosted and as instructed by ninrod.
-
some command-line utilities like
-
deps-new, a Clojure tool for handily creating projects
This repository arose from a need to be able to play and experiment with Clojure and functional programming in general in environments that are behind a corporate firewall and thus make downloading artifacts and installing executables difficult or at the very least unpleasant.
Warning
The produced image is by no means minimal and it is not designed to be. On the contrary, a handful of development tools deemed useful are installed to make for a more enjoyable developer experience. This, and above all the local versions of the Emacs package archives, leads to a large image size, currently around 3.5 GB.
The only prerequisite is a container platform like Docker or Podman.
The following are instructions for novices.
Clone this repository using Git
git clone https://github.com/tdinev/clojure-container-ide.git
or download and extract the ZIP archive.
Build the OCI image:
docker build -t clojure-ide clojure-container-ide
clojure-ide
denotes the name of the image, its tag is latest
(since no tag has explicitly been specified), and clojure-container-ide
is the name of the directory containing the contents of this repository.
This step may take some time (probably up to two minutes) as several packages need to be downloaded.
Spin off a container in interactive mode:
docker run -it --name clojure-dev clojure-ide
The container will be called clojure-dev
in this case.
You are now in a bash environment. You can play around with the Clojure REPL:
clojure
(You can exit the REPL by sending the EOF
character, usually by typing CTRL+D
or CTRL+Z
.)
or you can create a new application using deps-new:
clojure -Tnew app :name tdinev/demo
Interacting (via Git Bash on Windows) looks like this:
You can exit the container from within by typing
exit
in the shell.
If the container is exited, you can resume it to avoid the somewhat long waiting time when creating a new one
docker container start clojure-dev
docker attach clojure-dev
If you want to spawn off a bash as root
in a running container (e.g., to install further packages), you can use
docker exec -it -u root clojure-dev bash
provided the container name is clojure-dev
.