Skip to content

Instantly share code, notes, and snippets.

@rhuss
Last active January 3, 2021 13:03
Show Gist options
  • Select an option

  • Save rhuss/6d3c0c687fb4ec39c3e4 to your computer and use it in GitHub Desktop.

Select an option

Save rhuss/6d3c0c687fb4ec39c3e4 to your computer and use it in GitHub Desktop.
The Holy Grail of a Minimal, Headless, OpenJDK JRE 8
# Build for 206 MB JRE 1.8.0_60 (192 MB in size) with Alping and glibc
FROM alpine:3.2
ENV JRE=jre1.8.0_60 \
JAVA_HOME=/opt/jre
# That's the an EA from OpenJDK.net
# Courtesy to https://github.com/frol/docker-alpine-oraclejdk8 from where the setup of glibc is borrowed
RUN apk add --update wget ca-certificates && \
cd /tmp && \
wget "https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-2.21-r2.apk" \
"https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-bin-2.21-r2.apk" && \
apk add --allow-untrusted glibc-2.21-r2.apk glibc-bin-2.21-r2.apk && \
/usr/glibc/usr/bin/ldconfig /lib /usr/glibc/usr/lib && \
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \
mkdir /opt && \
wget http://www.java.net/download/jdk8u60/archive/b18/binaries/jre-8u60-ea-bin-b18-linux-x64-02_jun_2015.tar.gz -O /tmp/${JRE}.tgz && \
cd /opt && tar zxvf /tmp/${JRE}.tgz && \
ln -s /opt/${JRE} /opt/jre && \
ln -s /opt/jre/bin/java /usr/bin/java && \
apk del wget ca-certificates && \
cd /opt/jre/lib/amd64 && rm libjavafx_* libjfx* libfx* && \
cd /opt/jre/lib/ && rm -rf ext/jfxrt.jar jfxswt.jar javafx.properties font* && \
rm /tmp/* /var/cache/apk/*
@flyinprogrammer
Copy link
Copy Markdown

So I'm going to go do some research but maybe someone here knows already?
There seems to be already maintained openjdk packages in the apk repos: https://pkgs.alpinelinux.org/package/community/x86_64/openjdk8

And it requires musl instead of a glibc package -- is it documented anywhere that openjdk and/or oracle jdk require glibc? or one requires one vs the other?

@jokester
Copy link
Copy Markdown

Oracle JDK is not working with musl, see this issue.
Alpine's OpenJDK build seems to be fine with musl (and w/o glibc), I'm running a artifactory instance with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment