Fork me on GitHub

I am running lein uberjar in my local machine and it’s running correctly, but when I run lein uberjar while creating an image like so:

1   FROM clojure:openjdk-8-lein
  1 RUN apt-get update
  2 RUN apt-get -y install npm
  3 RUN npm install -g shadow-cljs
  4 WORKDIR "/humboi"
  5 COPY . .
  6 RUN lein uberjar
  7 EXPOSE 3000
  8 CMD ["java" "-jar" "target/uberjar/humboi.jar"]
I get the error:
#12 570.0 Retrieving re-frisk/re-frisk/1.5.1/re-frisk-1.5.1.jar from clojars
#12 572.5 Failed to read artifact descriptor for cljsjs:react:jar:16.13.0-0
#12 572.5 Failed to read artifact descriptor for ns-tracker:ns-tracker:jar:0.4.0
#12 572.5 This could be due to a typo in :dependencies, file system permissions, or network issues.
#12 572.5 If you are behind a proxy, try setting the 'http_proxy' environment variable.
executor failed running [/bin/sh -c lein uberjar]: exit code: 1
How to fix this?


you can always build the uberjar outside and copy it in with the docker file. the way youre building would result in a really fat docker image. i recommend doing all the builds outside and using something like openjdk:16 as the base image


also if youre building outside in a CI for example, the CI can cache the dependencies. you dont have the download it again unless the dependencies change


final docker images should be as lean as possible


if you have a ci/cd pipeline, your approach would require to push the jar files to version control and put an extra step between committing the code and pushing


do you know why this dockerfile isn’t working?


no, build the jar using the lein uberjar command using the ci and only have COPY app.jar . in the dockerfile


looking at the error, could be a maven glitch, not sure. is it repeatedly happening? i generally retry on these errors


as for the ci thing, have a docker file like

FROM openjdk:16

COPY target/uberjar/humboi.jar .

ENTRYPOINT ["java", "-jar", "humboi.jar"]
and run the following steps in the ci:
- clone the repo
- lein uberjar
- docker build .


if you use something like GitHub Actions as your CI, is quite easy to install and setup java and lein on the CI: