Fork me on GitHub
#docker
<
2018-02-22
>
hawari04:02:37

Hi everyone, I was wondering on how to build a clojure project correctly, as of now my Dockerfile looks like this:

FROM clojure:lein-2.8.1-alpine

WORKDIR /app

ADD . /app

RUN lein ring uberjar

EXPOSE 1234

CMD ["java", "-jar", "target/projectname-0.1.0-standalone.jar"]
There's a caveat to this, if I were to update my project version in project.clj, I need to update the CMD line as well. Is this acceptable? Or is there any other way to make it better?

gklijs05:02:21

How I do it is setting a fixed name for the uberjar in the project.clj config. And use an Alpine java image, and put the jar in, most times as App.jar, and running it will be the same always.

valtteri05:02:26

^ this and you can ‘lift’ versioning to the docker image level by using tags.. I mean, when you build the image you can tag it like my-company/projectname:0.1.0-standalone, where my-company/projectname is the name of the image and stuff after : is the version tag. This is how most public docker images are versioned.