Development workflow for Clojure webapp with Docker

I'm trying to get started with Docker to develop a web application with Clojure, and I'm not sure which way. From what I've read so far, as well as looking at the official Docker Clojure repo , there are basically two possible ways:

  • calling lein ring server (interactively or as a CMD in a Docker file) or
  • use the Docker file to compile your application in uberjar and use java -jar as CMD in the resulting jar file.

The first seems to me problematic in the sense that the development environment is not so close to the working environment that we probably use the profile :dev leiningen, which adds material that is strictly not needed in production (providing both several tools and β€œinformation” , i.e. code on an open production server is always a good idea). The latter, however, has a completely opposite problem: now each change requires mainly image restoration (I think, edit the compilation cycle), so you lose the beautiful lein ring recompile by modification functionality.

How do people use this combination in practice?

PS: I know that in practice there may be some other ways of working (for example, using Immutant or Tomcat as a deployment target or using a CI server such as Hudson, etc.). I first ask about the most basic setup.

+5
source share
3 answers

My team and I decided to optimize fast feedback while developing and minimizing the number of moving parts in our deployments. As a result, we decided to use the lein ring server in development and decided to send uberjar for our deployment. I did this with code running in docker containers and without them.

I would not want to return to using a development workflow that did not allow me to see the results of code changes as quickly as possible. In my opinion, quick feedback far outweighs the risk of services running a little differently between my local machine and production.

In addition, nothing prevents me from changing a couple of lines of code, and then starting a local service that works much closer to my production setup (either it launches an embedded docker image, or uberjar is created locally).

+1
source

There is nothing stopping you from working in production mode with Leiningen. Just use:

 lein with-profile production ring server 

I have successfully used both approaches, although we have applied the uberjar approach because it gives faster startup time.

+1
source

I am using the second java -jar ... to deploy my production web application (not yet using Docker). This creates an editing-compilation cycle, as you said. But I am not recompiling for every change. Only when I'm ready to free myself do I create uberjar. CI course is always recommended.

0
source

Source: https://habr.com/ru/post/1207742/


All Articles