-
Notifications
You must be signed in to change notification settings - Fork 235
Add amazon-corretto base image (21, 17) #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# | ||
# Scala and sbt Dockerfile | ||
# | ||
# https://github.com/sbt/docker-sbt | ||
# | ||
|
||
# Pull base image | ||
ARG BASE_IMAGE_TAG | ||
FROM amazoncorretto:${BASE_IMAGE_TAG:-21.0.5-al2023} | ||
|
||
# Env variables | ||
ARG SCALA_VERSION | ||
ENV SCALA_VERSION=${SCALA_VERSION:-3.3.4} | ||
ARG SBT_VERSION | ||
ENV SBT_VERSION=${SBT_VERSION:-1.10.5} | ||
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 \ | ||
dnf -y update && \ | ||
dnf -y install tar gzip procps git rpm && \ | ||
rm -rf /var/cache/dnf/* && \ | ||
dnf clean all | ||
|
||
# Install sbt | ||
RUN \ | ||
curl -fsL --show-error "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 --show-error $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 && \ | ||
mkdir -p /test && \ | ||
case $SCALA_VERSION in \ | ||
"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 ;; \ | ||
*) echo "println(util.Properties.versionMsg)" > /test/test.scala ;; \ | ||
esac && \ | ||
scala -nocompdaemon test/test.scala && \ | ||
rm -fr test | ||
|
||
# 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 \ | ||
rm -rf /tmp/..?* /tmp/.[!.]* * && \ | ||
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"] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.