Skip to content

Instantly share code, notes, and snippets.

@vharmain
Last active March 13, 2018 13:19
Show Gist options
  • Save vharmain/9dda15880b1b93ede2ec2045040b0d26 to your computer and use it in GitHub Desktop.
Save vharmain/9dda15880b1b93ede2ec2045040b0d26 to your computer and use it in GitHub Desktop.
Dockerized ClojureScript development environment

How it works

- '.:/usr/src/app' (under base) will mount your project dir . into the container(s) path /usr/src/app. This way both your host machine and container(s) see the same files and any changes will persist on your host machine after container has terminated. Additionally there’s a separate volume for Maven cache, which you want to share between your containers (otherwise maven downloads dependencies each time you execute lein commands). Volume(s) defined at the bottom will ‘survive’ until they’re explicitly deleted.

Usage

  • docker-compose run lein <args> executes any lein tasks. Example: docker-compose run lein clean
  • docker-compose up figwheel fires up figwheel which will be accessible from host on port 3449. (ctrl-c will quit). You need to use up instead of run because run doesn’t allocate port mappings and therefore you’d never be able to access index.html from your host machines browser.
  • docker-compose run shell starts a bash session in container, for exploring and fun.
  • docker-compose down removes all containers.
  • docker-compose down -v shuts down all containers and removes mvn_cache volume.
version: '2'
services:
base:
image: clojure:lein
working_dir: /usr/src/app
volumes:
- '.:/usr/src/app'
- 'mvn_cache:/root/.m2'
lein:
extends:
service: base
entrypoint: lein
figwheel:
extends:
service: lein
command: figwheel
tty: true
ports:
- '3449:3449'
shell:
extends:
service: base
command: bash
volumes:
mvn_cache: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment