CSS Compilation

We have a Clojure project setup with CircleCi 2.0. The CSS is written in Stylus.

We tried to use a Stylus Docker image to compile the CSS.

  - run:
      name: Build CSS
      command: |
        mkdir `pwd`/resources/public/css
        docker run -it --rm \
        -v `pwd`/src/css:/inputfiles \
        -v `pwd`/resources/public/css:/outputfiles \
        gruen/stylus /inputfiles/forecast.styl -o /outputfiles/forecast.css

It works on our local machines but not on CircleCI. For some reason the Stylus Docker image can’t mount the directory containing the Stylus source files

We then tried install and run stylus without Docker:

  - run:
      name: Build CSS
      command: |
        npm install -g stylus
        stylus src/css -o resources/public/css

It can’t find npm because the primary image is Clojure.

What would be a suitable solution to compile the CSS?

I’m assuming you are using the docker executor? If so, volume mounts cannot be done, which is why this isn’t working.

You can:

  1. use the machine executor, which can do volume mounts
  2. install NodeJS/npm into your Clojure container
  3. make a custom Docker image that has everything you need, then keep using the docker executor

Option 3 is my suggestion.