FROM docker.io/library/eclipse-temurin:21-jdk ARG SCALA_VERSION ENV SCALA_VERSION ${SCALA_VERSION:-3.6.4} ARG SBT_VERSION ENV SBT_VERSION ${SBT_VERSION:-1.10.11} # git is required for many build activities # python3 is required for pre-commit # docker is required for certain DinD cases RUN apt-get update RUN apt-get install -y curl bash git docker python3 python3-pip ca-certificates RUN pip3 install pre-commit # Ensure that this image recognizes the self-signed registry certificate. COPY registry.garrity.co.crt /usr/local/share/ca-certificates RUN update-ca-certificates # install node (lts) for checkout -- requires a modern version RUN curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s lts # Create the user - builds do not run as root. RUN groupadd -g 1111 -r builder RUN useradd -u 1111 -m -g 1111 -r -s /bin/bash builder # Switch to the build user. Everything else is installed at this level. USER builder WORKDIR /home/builder # Coursier provides all Scala development requirements. RUN curl -fLo coursier https://github.com/coursier/launchers/raw/master/coursier RUN chmod +x coursier RUN ./coursier setup --yes RUN ./coursier update RUN rm ./coursier RUN mkdir -p /home/builder/.local/bin ENV PATH="${PATH}:/home/builder/.local/share/coursier/bin" ENV PATH="${PATH}:/home/builder/.local/bin" # Allow empty -- this is used for bootstrapping SBT. RUN mkdir -p /home/builder/.config/sbt RUN echo "--allow-empty" > /home/builder/.config/sbt/sbtopts # Make Git not complain. RUN git config --global init.defaultBranch main # Warm up the SBT cache (taken from official SBT Docker image). 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