Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Development workflow for a Clojure webapp with Docker

Tags:

docker

clojure

I'm trying to get started with Docker for developing a web application with Clojure and am unsure which way to go. From what I've read so far and also looking at the offical Docker Clojure repo, there are basically two possible ways:

  • call lein ring server (interactively or as a CMD in a Dockerfile) or
  • use a Dockerfile to compile your application into an uberjar and use java -jar as the CMD on the resulting jar file.

The former seems to me to be problematic in the sense that the dev environment is not as close as possible to the production environment, given that we're probably using a :dev leiningen profile adding stuff that one would strictly not want in production (providing as few tools and "information", i.e. code on an exposed production server is always a good idea). The latter, however, seems to have the exact opposite problem: Now every change requires basically a rebuild of the image (think edit-compile-run cycle), so you would lose lein rings nice re-compile on modification functionality.

How are people using this combination in practice?

PS: I'm aware that there might be some other modes of operation in practice (e.g. using Immutant or Tomcat as the deployment target or using a CI server like Hudson etc.). I'm asking about the most basic setup first here.

like image 228
schaueho Avatar asked Nov 01 '22 13:11

schaueho


1 Answers

My team and I have opted to optimize rapid feedback while developing and minimize the number of moving parts in our deploys. As a result we've opted to use lein ring server in development and opt to ship an uberjar for our deployment. I've done this with code running in docker containers and without them.

I wouldn't want to go back to using a development workflow that didn't enable seeing the results of changing code as quickly as possible. In my mind, the rapid feedback far outweighs the risk of the running services slightly differently between my local machine and production.

Also, nothing stops me from changing a couple lines of code and then starting up a local service that is running much closer to my production setup (either running a built docker image or building an uberjar locally).

like image 78
Jake McCrary Avatar answered Nov 09 '22 06:11

Jake McCrary