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