diff --git a/Dockerfile b/Dockerfile index b528f83..4dc9024 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,9 @@ FROM alpine:3.18 #ARG version=8.382.05.1 -ARG version=22.0.0.37 +#ARG version=22.0.0.37.1; builds, no maven +ARG version=21.0.2.14.1 +# works with maven #slim build with jlink to keep jre size at a minimum RUN wget -O /THIRD-PARTY-LICENSES-20200824.tar.gz https://corretto.aws/downloads/resources/licenses/alpine/THIRD-PARTY-LICENSES-20200824.tar.gz && \ @@ -12,17 +14,31 @@ RUN wget -O /THIRD-PARTY-LICENSES-20200824.tar.gz https://corretto.aws/downloads SHA_SUM="6cfdf08be09f32ca298e2d5bd4a359ee2b275765c09b56d514624bf831eafb91" && \ echo "${SHA_SUM} /etc/apk/keys/amazoncorretto.rsa.pub" | sha256sum -c - && \ echo "https://apk.corretto.aws" >> /etc/apk/repositories && \ - apk add --no-cache amazon-corretto-22=$version-r0 binutils maven && \ + apk add --no-cache amazon-corretto-21=$version-r0 binutils && \ /usr/lib/jvm/default-jvm/bin/jlink --add-modules "$(java --list-modules | sed -e 's/@[0-9].*$/,/' | tr -d \\n)" --no-man-pages --no-header-files --strip-debug --output /opt/corretto-slim && \ - apk del binutils amazon-corretto-20 && \ + apk del binutils amazon-corretto-21 && \ mkdir -p /usr/lib/jvm/ && \ - mv /opt/corretto-slim /usr/lib/jvm/java-22-amazon-corretto && \ - ln -sfn /usr/lib/jvm/java-22-amazon-corretto /usr/lib/jvm/default-jvm + mv /opt/corretto-slim /usr/lib/jvm/java-21-amazon-corretto && \ + ln -sfn /usr/lib/jvm/java-21-amazon-corretto /usr/lib/jvm/default-jvm + ENV LANG C.UTF-8 ENV JAVA_HOME=/usr/lib/jvm/default-jvm +#ENV JAVA_HOME="$(/usr/libexec/java_home -v 21)" ENV PATH=$PATH:/usr/lib/jvm/default-jvm/bin +# ====== maven setup, new layer ====== +ENV MAVEN_VERSION 3.9.2 +ENV MAVEN_HOME /usr/lib/mvn +ENV PATH $MAVEN_HOME/bin:$PATH + +RUN wget http://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz && \ + tar -zxvf apache-maven-$MAVEN_VERSION-bin.tar.gz && \ + rm apache-maven-$MAVEN_VERSION-bin.tar.gz && \ + mv apache-maven-$MAVEN_VERSION /usr/lib/mvn + +# ==================== + ARG APPLICATION_USER=appuser RUN adduser --no-create-home -u 1000 -D $APPLICATION_USER && \ mkdir /app && \ diff --git a/README.md b/README.md index 8eb228f..fdf181e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ A speedrun attempt to clone [MAL](https://myanimelist.net/) lists into a github pages subdomain, using SpringBoot. IaC automation provided by OCI containers, compose, github actions and scaffolding with shellscript. +The second attempt is to make the app ~**blazingly**~ fast by having a slim container image build, featuring: +- alpine as OCI container distro; +- [amazon-corretto-22]() as JRE; +- symbol stripping with [jlink](); +- to avoid layer bloat, ~only one~ two are being used to download and remove build dependencies. Dockerfile inspired by the official [corretto](https://github.com/corretto/corretto-docker/) repo + ## Usage 1. clone repository with SSH and enter directory