Public | Automated Build

Last pushed: a year ago
Short Description
Creates an alpine-based Clojure installation with leiningen and phantomjs
Full Description

Clojure Alpine Image with PhantomJS

Creates an Alpine-based Clojure environment
with Leiningen and PhantomJS.

This is an excellent image when working with ClojureScript and the need for some
tests with virtual browsers, for example
with lein doo and PhantomJS.

Uses the latest official clojure:alpine
image and adds PhantomJS with a patch for Alpine Linux.


Local Machine

Copy your code into the container to /code. You can do this by volume-mounting.
Let's assume the project's name is awesomeproject and it's a ClojureScript
project using lein-doo and phantomjs
(pre-installed in this image). To start the tests, we need to tell doo that it
should use the phantomjs runner to run the tests. We can do this by simply

lein doo phantom test once

Okay, let's bring the code and the container together to execute our tests:

docker run --rm -v ~/.m2:/root/.m2 -v awesomeproject:/code cmeter/clojure-phantomjs
  • --rm: removes the container after the tests finished. I like this option to
    don't mess up my system with unused containers
  • -v ~/.m2:/root/.m2: this is an optimization to use my local cache of my jar
    files in the container. The second
  • -v awesomeproject:/code: links my project to the container's folder /code

You can override the command to use your own leiningen test-aliases etc. As a
default, the container uses the command from above to start the tests with lein doo.


I am using this image in the GitLab CI and in CircleCI. The configuration is
simpler in the CI, since the complete repository is usually directly checked out
into the ci's runner environment.


A sample job-configuration of your ClojureScript project for the GitLab CI could
look like this:

  image: cmeter/clojure-phantomjs
  stage: test
    - lein doo phantom test once

And for a CircleCI 2.0 config, I am using it like this:

version: 2
      - image: cmeter/clojure-phantomjs
    working_directory: ~/code

      - checkout
      - restore_cache:
          - v1-dependencies-{{ checksum "project.clj" }}
          - v1-dependencies-
      - run: lein deps
      - save_cache:
            - ~/.m2
          key: v1-dependencies-{{ checksum "project.clj" }}
      - run: lein doo phantom test once
Docker Pull Command
Source Repository