Skip to content

Commit 14bc3d9

Browse files
committed
Add amazon-corretto base image (21, 17)
1 parent b28c743 commit 14bc3d9

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ jobs:
2626
'eclipse-temurin-17.0.13_11',
2727
'eclipse-temurin-alpine-23.0.1_11',
2828
'eclipse-temurin-alpine-21.0.5_11',
29-
'eclipse-temurin-alpine-17.0.13_11'
29+
'eclipse-temurin-alpine-17.0.13_11',
30+
'amazoncorretto-21.0.5',
31+
'amazoncorretto-17.0.13'
3032
]
3133
include:
3234
# https://github.com/graalvm/container/pkgs/container/graalvm-community
@@ -72,6 +74,15 @@ jobs:
7274
dockerfile: 'alpine.Dockerfile'
7375
baseImageTag: '17.0.13_11-jdk-alpine'
7476
platforms: 'linux/amd64'
77+
# https://hub.docker.com/_/amazoncorretto/tags
78+
- javaTag: 'amazoncorretto-21.0.5'
79+
dockerContext: 'amazoncorretto'
80+
baseImageTag: '21.0.5'
81+
platforms: 'linux/amd64'
82+
- javaTag: 'amazoncorretto-17.0.13'
83+
dockerContext: 'amazoncorretto'
84+
baseImageTag: '17.0.13'
85+
platforms: 'linux/amd64'
7586
exclude:
7687
# https://github.com/VirtusLab/scala-cli/issues/3130
7788
- scalaVersion: '3.5.2'

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Images are updated daily
99
Available JDK base images:
1010
* eclipse-temurin
1111
* graalvm-ce
12+
* amazoncorretto
1213

1314
## Where to get images
1415

amazoncorretto/Dockerfile

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#
2+
# Scala and sbt Dockerfile
3+
#
4+
# https://github.com/sbt/docker-sbt
5+
#
6+
7+
# Pull base image
8+
ARG BASE_IMAGE_TAG
9+
FROM amazoncorretto:${BASE_IMAGE_TAG:-21.0.5}
10+
11+
# Env variables
12+
ARG SCALA_VERSION
13+
ENV SCALA_VERSION=${SCALA_VERSION:-3.3.4}
14+
ARG SBT_VERSION
15+
ENV SBT_VERSION=${SBT_VERSION:-1.10.5}
16+
ARG USER_ID
17+
ENV USER_ID=${USER_ID:-1001}
18+
ARG GROUP_ID
19+
ENV GROUP_ID=${GROUP_ID:-1001}
20+
21+
# Install git and rpm for sbt-native-packager (see https://github.com/sbt/docker-sbt/pull/114)
22+
RUN \
23+
yum -y update && \
24+
yum -y install tar gzip git rpm && \
25+
rm -rf /var/cache/yum/* && \
26+
yum clean all
27+
28+
# Install sbt
29+
RUN \
30+
curl -fsL --show-error "https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz" | tar xfz - -C /usr/share && \
31+
chown -R root:root /usr/share/sbt && \
32+
chmod -R 755 /usr/share/sbt && \
33+
ln -s /usr/share/sbt/bin/sbt /usr/local/bin/sbt
34+
35+
# Install Scala
36+
RUN \
37+
case $SCALA_VERSION in \
38+
"3"*) URL=https://github.com/lampepfl/dotty/releases/download/$SCALA_VERSION/scala3-$SCALA_VERSION.tar.gz SCALA_DIR=/usr/share/scala3-$SCALA_VERSION ;; \
39+
*) URL=https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz SCALA_DIR=/usr/share/scala-$SCALA_VERSION ;; \
40+
esac && \
41+
curl -fsL --show-error $URL | tar xfz - -C /usr/share && \
42+
mv $SCALA_DIR /usr/share/scala && \
43+
chown -R root:root /usr/share/scala && \
44+
chmod -R 755 /usr/share/scala && \
45+
ln -s /usr/share/scala/bin/* /usr/local/bin && \
46+
mkdir -p /test && \
47+
case $SCALA_VERSION in \
48+
"3"*) echo 'import java.io.FileInputStream;import java.util.jar.JarInputStream;val scala3LibJar = classOf[CanEqual[_, _]].getProtectionDomain.getCodeSource.getLocation.toURI.getPath;val manifest = new JarInputStream(new FileInputStream(scala3LibJar)).getManifest;val ver = manifest.getMainAttributes.getValue("Implementation-Version");@main def main = println(s"Scala version ${ver}")' > /test/test.scala ;; \
49+
*) echo "println(util.Properties.versionMsg)" > /test/test.scala ;; \
50+
esac && \
51+
scala -nocompdaemon test/test.scala && \
52+
rm -fr test
53+
54+
# Symlink java to have it available on sbtuser's PATH
55+
RUN ln -s /opt/java/openjdk/bin/java /usr/local/bin/java
56+
57+
# Add and use user sbtuser
58+
RUN groupadd --gid $GROUP_ID sbtuser && useradd -m --gid $GROUP_ID --uid $USER_ID sbtuser --shell /bin/bash
59+
USER sbtuser
60+
61+
# Switch working directory
62+
WORKDIR /home/sbtuser
63+
64+
# Prepare sbt (warm cache)
65+
RUN \
66+
sbt sbtVersion && \
67+
mkdir -p project && \
68+
echo "scalaVersion := \"${SCALA_VERSION}\"" > build.sbt && \
69+
echo "sbt.version=${SBT_VERSION}" > project/build.properties && \
70+
echo "// force sbt compiler-bridge download" > project/Dependencies.scala && \
71+
echo "case object Temp" > Temp.scala && \
72+
sbt compile && \
73+
rm -r project && rm build.sbt && rm Temp.scala && rm -r target
74+
75+
# Link everything into root as well
76+
# This allows users of this container to choose, whether they want to run the container as sbtuser (non-root) or as root
77+
USER root
78+
RUN \
79+
rm -rf /tmp/..?* /tmp/.[!.]* * && \
80+
ln -s /home/sbtuser/.cache /root/.cache && \
81+
ln -s /home/sbtuser/.sbt /root/.sbt && \
82+
if [ -d "/home/sbtuser/.ivy2" ]; then ln -s /home/sbtuser/.ivy2 /root/.ivy2; fi
83+
84+
# Switch working directory back to root
85+
## Users wanting to use this container as non-root should combine the two following arguments
86+
## -u sbtuser
87+
## -w /home/sbtuser
88+
WORKDIR /root
89+
90+
CMD ["sbt"]

0 commit comments

Comments
 (0)