docker

ghadi 2018-08-29T15:35:34.000100Z

lein is not part of clojure -- third party build tool

ghadi 2018-08-29T15:35:42.000100Z

I generally avoid putting lein in production images

ghadi 2018-08-29T15:36:03.000200Z

instead opting to make an uberjar -- then build a cut-down image to run it

ghadi 2018-08-29T15:36:31.000100Z

alpine isn't really officially supported until JDK11 - which comes out in September

2018-08-29T15:36:31.000200Z

Yeah so for me cljs is my aim but I'm using deps.edn so I need clojure

ghadi 2018-08-29T15:36:50.000200Z

if you use deps.edn the easiest thing is to run the linux installer script within the docker build

2018-08-29T15:37:00.000200Z

yeah

2018-08-29T15:37:07.000100Z

that's what's working for me rn https://clojure.org/guides/getting_started#_installation_on_linux

2018-08-29T15:37:18.000200Z

doesn't that suffice for everyone?

ghadi 2018-08-29T15:37:25.000200Z

(TLDR there was a JDK8 alpine build, then none for JDK9/10, coming officially back for JDK11)

2018-08-29T15:37:29.000100Z

i guess you won't have a repl but why would one need it?

2018-08-29T15:37:54.000100Z

I built something that works

ghadi 2018-08-29T15:37:58.000200Z

what do you mean? If you have the clojure jar available, you can get a REPL

2018-08-29T15:38:02.000100Z

trying to stretch it and see it breaks

ghadi 2018-08-29T15:38:09.000100Z

java -cp clojure.jar clojure.main

2018-08-29T15:38:19.000100Z

ah yeah

2018-08-29T15:38:33.000100Z

but the repl via clj needs rlwrap

ghadi 2018-08-29T15:38:58.000100Z

right, that's just a convenience for non-brutal terminal interaction

ghadi 2018-08-29T15:39:07.000100Z

you still have a normal repl by launching clojure

2018-08-29T15:39:21.000100Z

but yeah what i have seems to work so far but I'm not 100% sure yet

2018-08-29T15:39:25.000200Z

yeah

ghadi 2018-08-29T15:39:26.000100Z

(I missed the beginning of this convo: What are you trying to do?)

ghadi 2018-08-29T15:39:35.000200Z

:simple_smile:

2018-08-29T15:39:47.000100Z

Trying to get clojure on an alpine image

ghadi 2018-08-29T15:39:54.000200Z

ah

ghadi 2018-08-29T15:40:04.000100Z

glibc or musl?

2018-08-29T15:41:13.000100Z

musl

ghadi 2018-08-29T15:41:26.000100Z

there's a dockerfile in the reply ^

ghadi 2018-08-29T15:41:49.000200Z

you can get it to 30MB -- I wouldn't recommend Alpine musl JDK, because that limits you to JDK8

2018-08-29T15:41:52.000100Z

but now trying with a base alpine image

2018-08-29T15:42:07.000100Z

I want jdk8 because that's stable

2018-08-29T15:42:41.000100Z

hmm I guess I don't have to hold so tightly to alpine

2018-08-29T15:43:33.000200Z

I have this

FROM alpine:3.8

RUN apk update && apk add nodejs-npm openjdk8 chromium git curl

RUN curl -O <https://download.clojure.org/install/linux-install-1.9.0.391.sh>
RUN chmod +x linux-install-1.9.0.391.sh
RUN ./linux-install-1.9.0.391.sh
RUN rm linux-install-1.9.0.391.sh

RUN npm install -g yarn

ghadi 2018-08-29T15:43:34.000200Z

I use jlink, an official tool to make a smaller JVM

2018-08-29T15:43:38.000100Z

waiting for the build to finish

ghadi 2018-08-29T15:43:45.000200Z

that seems legit

2018-08-29T15:44:14.000200Z

kinda bloated because I need to do browser tests haha

ghadi 2018-08-29T15:44:17.000100Z

what's the chromium for?

ghadi 2018-08-29T15:44:17.000300Z

ah

2018-08-29T15:44:55.000100Z

Worked ok with base clojure:alpine now trying with alpine:3.8

2018-08-29T15:45:06.000100Z

but image is still not under 100M

2018-08-29T15:45:14.000100Z

which isn't a hard requirement but cool to have

2018-08-29T15:46:08.000100Z

weird how clojure:alpine doesn't have clojure

ghadi 2018-08-29T15:46:23.000100Z

yeah they're using a name that sounds official but isn't

ghadi 2018-08-29T15:46:46.000200Z

there's some circle-CI images that use tools.deps that you can use as inspiration. They're not small though

2018-08-29T15:47:09.000100Z

clojure:tools-deps-alpine has clojure

2018-08-29T15:47:19.000100Z

You are just using wrong tag

2018-08-29T15:48:24.000100Z

hmmmm

2018-08-29T15:48:59.000100Z

not listed here https://docs.docker.com/samples/library/clojure/

ghadi 2018-08-29T15:49:13.000100Z

yeah that list isn't complete

ghadi 2018-08-29T15:49:20.000100Z

@delaguardo is right

2018-08-29T15:49:33.000100Z

but listed here) https://hub.docker.com/_/clojure/

ghadi 2018-08-29T15:49:39.000100Z

FROM openjdk:10 as jdk
RUN jlink \
  --strip-debug \
  --compress=1 \
  --vm=server \
  --output /tmp/linkedjdk \
  --add-modules <http://java.se|java.se>

FROM debian:stretch-slim
COPY --from=jdk /tmp/linkedjdk /jdk/
# This is temporarily necessary as it appears the new OpenJDK TrustStore is incomplete
# Apparently, AWS's Step Function endpoint uses a different signing root than S3
COPY --from=jdk /docker-java-home/lib/security/cacerts /jdk/lib/security/
COPY clojure.jar /app
ENTRYPOINT ["/jdk/bin/java" "-jar" "/app/clojure.jar"]
That's a full glibc jvm with debian for about 120MB

ghadi 2018-08-29T15:49:53.000100Z

you can remove modules and get smaller, but you'll lose some parts of the jdk

2018-08-29T15:50:14.000200Z

hmm I probably don't want that

2018-08-29T15:50:47.000100Z

I could just use clojure:tools-deps-alpine and save myself the pain of maintaining things

ghadi 2018-08-29T15:51:05.000100Z

yup ^

2018-08-29T15:51:16.000100Z

I mean I probably don't want to lose parts of the jdk > hmm I probably don't want that

2018-08-29T15:53:11.000100Z

Yes, nothing fancy in there)

2018-08-29T15:53:18.000100Z

but uses $CLOJURE_VERSION

2018-08-29T15:53:21.000100Z

ok I can use this

2018-08-29T15:53:26.000100Z

I didn't want fancy

2018-08-29T15:53:27.000100Z

🙂

2018-08-29T15:53:39.000100Z

I wonder why they installed rlwrap though

2018-08-29T15:53:49.000100Z

since I assume people won't want a repl 😛

2018-08-29T15:54:05.000100Z

this is nice

ghadi 2018-08-29T15:54:25.000100Z

they should change ENV to ARG on CLOJURE_VERSION

2018-08-29T15:54:40.000100Z

I wonder why the name tools-deps-alpine I couldn't have get that via a google search

2018-08-29T15:55:21.000100Z

probably should replace clojure:alpine with this

2018-08-29T15:55:30.000100Z

*they should probably

2018-08-29T15:56:15.000100Z

clojure:alpine historically reserved for lein tool not for tools-deps

2018-08-29T15:56:32.000100Z

what does tools deps mean if I may ask?

2018-08-29T15:56:53.000100Z

I was searching google for a lot of things but not tools deps 🙂

2018-08-29T15:57:10.000100Z

the name of the build tool - https://github.com/clojure/tools.deps.alpha

2018-08-29T15:57:56.000100Z

related to deps.edn?

2018-08-29T15:58:17.000100Z

yes

2018-08-29T15:58:31.000100Z

Ok then it's what I want

2018-08-29T15:59:07.000100Z

deps.edn and tools.deps works together only

2018-08-29T15:59:45.000100Z

and if you have a closer look into clojure executable script you will find something related to tools.deps

2018-08-29T16:00:21.000100Z

hmmm thanks I guess it's what I want because I want to make sure my deps.edn installs succeed