docker

hawari 2018-02-22T04:48:37.000110Z

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?

gklijs 2018-02-22T05:11:21.000014Z

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.

πŸ‘ 1
valtteri 2018-02-22T05:56:26.000260Z

^ 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.

πŸ‘ 1