Fork me on GitHub
#docker
<
2018-08-29
>
ghadi15:08:34

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

ghadi15:08:42

I generally avoid putting lein in production images

ghadi15:08:03

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

ghadi15:08:31

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

urbanslug15:08:31

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

ghadi15:08:50

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

urbanslug15:08:18

doesn't that suffice for everyone?

ghadi15:08:25

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

urbanslug15:08:29

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

urbanslug15:08:54

I built something that works

ghadi15:08:58

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

urbanslug15:08:02

trying to stretch it and see it breaks

ghadi15:08:09

java -cp clojure.jar clojure.main

urbanslug15:08:33

but the repl via clj needs rlwrap

ghadi15:08:58

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

ghadi15:08:07

you still have a normal repl by launching clojure

urbanslug15:08:21

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

ghadi15:08:26

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

urbanslug15:08:47

Trying to get clojure on an alpine image

ghadi15:08:04

glibc or musl?

ghadi15:08:26

there's a dockerfile in the reply ^

ghadi15:08:49

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

urbanslug15:08:52

but now trying with a base alpine image

urbanslug15:08:07

I want jdk8 because that's stable

urbanslug15:08:41

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

urbanslug15:08:33

I have this

FROM alpine:3.8

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

RUN curl -O 
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

ghadi15:08:34

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

urbanslug15:08:38

waiting for the build to finish

ghadi15:08:45

that seems legit

urbanslug15:08:14

kinda bloated because I need to do browser tests haha

ghadi15:08:17

what's the chromium for?

urbanslug15:08:55

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

urbanslug15:08:06

but image is still not under 100M

urbanslug15:08:14

which isn't a hard requirement but cool to have

urbanslug15:08:08

weird how clojure:alpine doesn't have clojure

ghadi15:08:23

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

ghadi15:08:46

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

delaguardo15:08:09

clojure:tools-deps-alpine has clojure

delaguardo15:08:19

You are just using wrong tag

ghadi15:08:13

yeah that list isn't complete

ghadi15:08:20

@delaguardo is right

ghadi15:08:39

FROM openjdk:10 as jdk
RUN jlink \
  --strip-debug \
  --compress=1 \
  --vm=server \
  --output /tmp/linkedjdk \
  --add-modules 

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

ghadi15:08:53

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

urbanslug15:08:14

hmm I probably don't want that

urbanslug15:08:47

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

urbanslug15:08:16

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

delaguardo15:08:11

Yes, nothing fancy in there)

urbanslug15:08:18

but uses $CLOJURE_VERSION

urbanslug15:08:21

ok I can use this

urbanslug15:08:26

I didn't want fancy

urbanslug15:08:39

I wonder why they installed rlwrap though

urbanslug15:08:49

since I assume people won't want a repl 😛

urbanslug15:08:05

this is nice

ghadi15:08:25

they should change ENV to ARG on CLOJURE_VERSION

urbanslug15:08:40

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

urbanslug15:08:21

probably should replace clojure:alpine with this

urbanslug15:08:30

*they should probably

delaguardo15:08:15

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

urbanslug15:08:32

what does tools deps mean if I may ask?

urbanslug15:08:53

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

urbanslug15:08:56

related to deps.edn?

urbanslug15:08:31

Ok then it's what I want

delaguardo15:08:07

deps.edn and tools.deps works together only

delaguardo15:08:45

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

urbanslug16:08:21

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