5

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 atthe offical Docker Clojure repo, there are basically two possible ways:

  • calllein ring server (interactively or as a CMD in a Dockerfile) or
  • use a Dockerfile to compile your application into an uberjar and usejava -jar as theCMD 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 loselein 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.

askedNov 26, 2014 at 13:43
schaueho's user avatar

3 Answers3

1

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 uselein 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).

answeredMay 19, 2016 at 4:46
Jake McCrary's user avatar
Sign up to request clarification or add additional context in comments.

Comments

1

There's nothing stopping you from running in production mode with Leiningen. Just use:

lein with-profile production ring server

I've used both approaches successfully, although we've settled on the uberjar approach because it gives faster startup times.

answeredMay 10, 2016 at 18:01
Paul Butcher's user avatar

Comments

0

I use the second optionjava -jar ... to deploy my web application to production (not using Docker yet). This creates an edit-compile-run cycle as you said. But I don't recompile for every change. Only when I'm ready to release I create the uberjar. Of cource CI is always recommended.

luchaninov's user avatar
luchaninov
6,8656 gold badges64 silver badges77 bronze badges
answeredJan 11, 2015 at 14:30
Kungi's user avatar

Comments

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.