From 8c93d7116991e9d82b51fdb417d79cdca63db851 Mon Sep 17 00:00:00 2001 From: kijuky <40358+kijuky@users.noreply.github.com> Date: Sun, 31 Jul 2022 17:47:55 +0900 Subject: [PATCH] Add amazon-corretto base image (17, 11) --- .github/workflows/build.yml | 11 +++++ README.md | 1 + amazoncorretto/Dockerfile | 92 +++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 amazoncorretto/Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c43eb2..734170b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,6 +26,8 @@ jobs: 'eclipse-temurin-jammy-8u352-b08', 'eclipse-temurin-focal-17.0.5_8', 'eclipse-temurin-focal-11.0.17_8', + 'amazoncorretto-17.0.6', + 'amazoncorretto-11.0.18' ] include: # https://github.com/graalvm/container/pkgs/container/graalvm-ce @@ -62,6 +64,15 @@ jobs: dockerContext: 'eclipse-temurin' baseImageTag: '11.0.17_8-jdk-focal' platforms: 'linux/amd64,linux/arm64' + # https://hub.docker.com/_/amazoncorretto/tags + - javaTag: 'amazoncorretto-17.0.6' + dockerContext: 'amazoncorretto' + baseImageTag: '17.0.6' + platforms: 'linux/amd64' + - javaTag: 'amazoncorretto-11.0.18' + dockerContext: 'amazoncorretto' + baseImageTag: '11.0.18' + platforms: 'linux/amd64' steps: - uses: actions/checkout@v3 - name: Set up QEMU diff --git a/README.md b/README.md index 224b90d..62efb6b 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Images are updated daily Available JDK base images: * eclipse-temurin * graalvm-ce +* amazoncorretto ## Where to get images diff --git a/amazoncorretto/Dockerfile b/amazoncorretto/Dockerfile new file mode 100644 index 0000000..696475c --- /dev/null +++ b/amazoncorretto/Dockerfile @@ -0,0 +1,92 @@ +# +# Scala and sbt Dockerfile +# +# https://github.com/sbt/docker-sbt +# + +# Pull base image +ARG BASE_IMAGE_TAG +FROM amazoncorretto:${BASE_IMAGE_TAG:-17.0.6} + +# Env variables +ARG SCALA_VERSION +ENV SCALA_VERSION ${SCALA_VERSION:-2.13.10} +ARG SBT_VERSION +ENV SBT_VERSION ${SBT_VERSION:-1.8.2} +ARG USER_ID +ENV USER_ID ${USER_ID:-1001} +ARG GROUP_ID +ENV GROUP_ID ${GROUP_ID:-1001} + +# Install git and rpm for sbt-native-packager (see https://github.com/sbt/docker-sbt/pull/114) +RUN yum -y update && \ + yum -y install tar gzip git rpm && \ + rm -rf /var/cache/yum/* && \ + yum clean all + +# Install sbt +RUN \ + curl -fsL "https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz" | tar xfz - -C /usr/share && \ + chown -R root:root /usr/share/sbt && \ + chmod -R 755 /usr/share/sbt && \ + ln -s /usr/share/sbt/bin/sbt /usr/local/bin/sbt + +# Install Scala +RUN \ + case $SCALA_VERSION in \ + "3"*) URL=https://github.com/lampepfl/dotty/releases/download/$SCALA_VERSION/scala3-$SCALA_VERSION.tar.gz SCALA_DIR=/usr/share/scala3-$SCALA_VERSION ;; \ + *) URL=https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz SCALA_DIR=/usr/share/scala-$SCALA_VERSION ;; \ + esac && \ + curl -fsL $URL | tar xfz - -C /usr/share && \ + mv $SCALA_DIR /usr/share/scala && \ + chown -R root:root /usr/share/scala && \ + chmod -R 755 /usr/share/scala && \ + ln -s /usr/share/scala/bin/* /usr/local/bin && \ + case $SCALA_VERSION in \ + "3"*) \ + echo '@main def main = println(s"Scala library version ${dotty.tools.dotc.config.Properties.versionNumberString}")' > test.scala && \ + # WORKAROUND: tput: terminal attributes: No such device or address + mv /usr/bin/tput /usr/bin/_tput && \ + scala test.scala && rm test.scala && \ + mv /usr/bin/_tput /usr/bin/tput ;; \ + *) \ + echo "println(util.Properties.versionMsg)" > test.scala && \ + scala -nocompdaemon test.scala && rm test.scala ;; \ + esac + +# Symlink java to have it available on sbtuser's PATH +RUN ln -s /opt/java/openjdk/bin/java /usr/local/bin/java + +# Add and use user sbtuser +RUN groupadd --gid $GROUP_ID sbtuser && useradd -m --gid $GROUP_ID --uid $USER_ID sbtuser --shell /bin/bash +USER sbtuser + +# Switch working directory +WORKDIR /home/sbtuser + +# Prepare sbt (warm cache) +RUN \ + sbt sbtVersion && \ + mkdir -p project && \ + echo "scalaVersion := \"${SCALA_VERSION}\"" > build.sbt && \ + echo "sbt.version=${SBT_VERSION}" > project/build.properties && \ + echo "// force sbt compiler-bridge download" > project/Dependencies.scala && \ + echo "case object Temp" > Temp.scala && \ + sbt compile && \ + rm -r project && rm build.sbt && rm Temp.scala && rm -r target + +# Link everything into root as well +# This allows users of this container to choose, whether they want to run the container as sbtuser (non-root) or as root +USER root +RUN \ + ln -s /home/sbtuser/.cache /root/.cache && \ + ln -s /home/sbtuser/.sbt /root/.sbt && \ + if [ -d "/home/sbtuser/.ivy2" ]; then ln -s /home/sbtuser/.ivy2 /root/.ivy2; fi + +# Switch working directory back to root +## Users wanting to use this container as non-root should combine the two following arguments +## -u sbtuser +## -w /home/sbtuser +WORKDIR /root + +CMD sbt