This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-09
Channels
- # announcements (5)
- # aws (5)
- # babashka (7)
- # beginners (152)
- # cider (10)
- # clj-kondo (30)
- # clj-on-windows (1)
- # cljs-dev (14)
- # cljsrn (19)
- # clojure (94)
- # clojure-australia (4)
- # clojure-europe (43)
- # clojure-nl (2)
- # clojure-uk (11)
- # clojurescript (16)
- # clojureverse-ops (5)
- # code-reviews (7)
- # community-development (6)
- # core-async (29)
- # cursive (50)
- # datomic (22)
- # docker (10)
- # figwheel-main (3)
- # fulcro (4)
- # graalvm (1)
- # introduce-yourself (2)
- # kaocha (9)
- # lambdaisland (2)
- # lsp (19)
- # malli (37)
- # off-topic (50)
- # polylith (8)
- # portal (1)
- # reagent (10)
- # rum (1)
- # shadow-cljs (24)
- # spacemacs (14)
- # yada (2)
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: https://github.com/marketplace/actions/setup-clojure