├── .github ├── dependabot.yml └── workflows │ └── build.yml ├── LICENSE ├── NOTICE ├── README.md ├── amazoncorretto └── Dockerfile ├── eclipse-temurin ├── Dockerfile └── alpine.Dockerfile ├── graalvm-ce └── Dockerfile └── graalvm-community └── Dockerfile /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | schedule: 11 | - cron: '0 0 * * *' 12 | 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-latest 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | scalaVersion: ['2.12.20', '2.13.16', '3.3.6', '3.7.1'] 21 | javaTag: [ 22 | 'graalvm-community-24.0.1', 23 | 'graalvm-community-21.0.2', 24 | 'graalvm-ce-22.3.3-b1-java17', 25 | 'eclipse-temurin-24.0.1_9', 26 | 'eclipse-temurin-21.0.7_6', 27 | 'eclipse-temurin-17.0.15_6', 28 | 'eclipse-temurin-alpine-24.0.1_9', 29 | 'eclipse-temurin-alpine-21.0.7_6', 30 | 'eclipse-temurin-alpine-17.0.15_6', 31 | 'amazoncorretto-al2023-21.0.7', 32 | 'amazoncorretto-al2023-17.0.15' 33 | ] 34 | include: 35 | # https://github.com/graalvm/container/pkgs/container/graalvm-community 36 | - javaTag: 'graalvm-community-24.0.1' 37 | dockerContext: 'graalvm-community' 38 | baseImageTag: '24.0.1-ol9' 39 | platforms: 'linux/amd64,linux/arm64' 40 | - javaTag: 'graalvm-community-21.0.2' 41 | dockerContext: 'graalvm-community' 42 | baseImageTag: '21.0.2-ol9' 43 | platforms: 'linux/amd64,linux/arm64' 44 | # https://github.com/graalvm/container/pkgs/container/graalvm-ce 45 | - javaTag: 'graalvm-ce-22.3.3-b1-java17' 46 | dockerContext: 'graalvm-ce' 47 | baseImageTag: 'ol9-java17-22.3.3-b1' 48 | platforms: 'linux/amd64,linux/arm64' 49 | # https://hub.docker.com/_/eclipse-temurin/tags 50 | - javaTag: 'eclipse-temurin-24.0.1_9' 51 | dockerContext: 'eclipse-temurin' 52 | baseImageTag: '24.0.1_9-jdk' 53 | platforms: 'linux/amd64,linux/arm64' 54 | - javaTag: 'eclipse-temurin-21.0.7_6' 55 | dockerContext: 'eclipse-temurin' 56 | baseImageTag: '21.0.7_6-jdk' 57 | platforms: 'linux/amd64,linux/arm64' 58 | - javaTag: 'eclipse-temurin-17.0.15_6' 59 | dockerContext: 'eclipse-temurin' 60 | baseImageTag: '17.0.15_6-jdk' 61 | platforms: 'linux/amd64,linux/arm64' 62 | # https://hub.docker.com/_/eclipse-temurin/tags?page=1&name=alpine 63 | - javaTag: 'eclipse-temurin-alpine-24.0.1_9' 64 | dockerContext: 'eclipse-temurin' 65 | dockerfile: 'alpine.Dockerfile' 66 | baseImageTag: '24.0.1_9-jdk-alpine' 67 | platforms: 'linux/amd64,linux/arm64/v8' 68 | - javaTag: 'eclipse-temurin-alpine-21.0.7_6' 69 | dockerContext: 'eclipse-temurin' 70 | dockerfile: 'alpine.Dockerfile' 71 | baseImageTag: '21.0.7_6-jdk-alpine' 72 | platforms: 'linux/amd64,linux/arm64/v8' 73 | - javaTag: 'eclipse-temurin-alpine-17.0.15_6' 74 | dockerContext: 'eclipse-temurin' 75 | dockerfile: 'alpine.Dockerfile' 76 | baseImageTag: '17.0.15_6-jdk-alpine' 77 | platforms: 'linux/amd64' 78 | # https://hub.docker.com/_/amazoncorretto/tags 79 | - javaTag: 'amazoncorretto-al2023-21.0.7' 80 | dockerContext: 'amazoncorretto' 81 | baseImageTag: '21.0.7-al2023' 82 | platforms: 'linux/amd64' 83 | - javaTag: 'amazoncorretto-al2023-17.0.15' 84 | dockerContext: 'amazoncorretto' 85 | baseImageTag: '17.0.15-al2023' 86 | platforms: 'linux/amd64' 87 | steps: 88 | - uses: actions/checkout@v4 89 | - name: Set up QEMU 90 | uses: docker/setup-qemu-action@v3.6.0 91 | - name: Set up Docker Buildx 92 | id: buildx 93 | uses: docker/setup-buildx-action@v3.10.0 94 | # with: 95 | # install: true 96 | - name: Available platforms 97 | run: echo ${{ steps.buildx.outputs.platforms }} 98 | - name: Get latest SBT version 99 | id: get_sbt_version 100 | run: | 101 | SBT_VERSION=$( 102 | curl --silent -L https://github.com/sbt/sbt/releases | 103 | grep -i -w -o '>[0-9]*\.[0-9]*\.[0-9]*' | 104 | grep -i -w -o '[0-9]*\.[0-9]*\.[0-9]*' | 105 | sort --version-sort | tail -n 1) 106 | [[ -z "$SBT_VERSION" ]] && { echo "Failed to get latest sbt version" ; exit 1; } 107 | echo "VERSION=$SBT_VERSION" >> $GITHUB_OUTPUT 108 | - name: Create docker tag 109 | id: create_docker_tag 110 | run: | 111 | TAG=sbtscala/scala-sbt:${{ matrix.javaTag }}_${{ steps.get_sbt_version.outputs.VERSION }}_${{ matrix.scalaVersion }} 112 | echo "TAG=$TAG" >> $GITHUB_OUTPUT 113 | - name: Build docker image 114 | uses: docker/build-push-action@v6 115 | with: 116 | context: ${{ matrix.dockerContext }} 117 | no-cache: true 118 | tags: ${{ steps.create_docker_tag.outputs.TAG }} 119 | file: ${{ matrix.dockerContext }}/${{ matrix.dockerfile || 'Dockerfile' }} 120 | build-args: | 121 | BASE_IMAGE_TAG=${{ matrix.baseImageTag }} 122 | SBT_VERSION=${{ steps.get_sbt_version.outputs.VERSION }} 123 | SCALA_VERSION=${{ matrix.scalaVersion }} 124 | load: true 125 | - name: Test docker image as root (default) 126 | if: ${{ !startsWith(matrix.scalaVersion, '2.12') }} 127 | # scala --version does not work on < 2.13 128 | run: | 129 | docker run "${{ steps.create_docker_tag.outputs.TAG }}" /bin/bash -c "scala --version && sbt --script-version" 130 | - name: Test docker image scala as sbtuser 131 | if: ${{ !startsWith(matrix.scalaVersion, '2.12') }} 132 | # scala --version does not work on < 2.13 133 | run: | 134 | docker run -u sbtuser -w /home/sbtuser "${{ steps.create_docker_tag.outputs.TAG }}" /bin/bash -c "scala --version && sbt --script-version" 135 | - name: Log in to DockerHub 136 | if: github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' 137 | uses: docker/login-action@v3 138 | with: 139 | username: ${{ secrets.DOCKERHUB_USERNAME }} 140 | password: ${{ secrets.DOCKERHUB_TOKEN }} 141 | - name: Rebuild and push ${{ matrix.platforms }} docker images 142 | if: github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' 143 | uses: docker/build-push-action@v6 144 | with: 145 | context: ${{ matrix.dockerContext }} 146 | file: ${{ matrix.dockerContext }}/${{ matrix.dockerfile || 'Dockerfile' }} 147 | tags: ${{ steps.create_docker_tag.outputs.TAG }} 148 | build-args: | 149 | BASE_IMAGE_TAG=${{ matrix.baseImageTag }} 150 | SBT_VERSION=${{ steps.get_sbt_version.outputs.VERSION }} 151 | SCALA_VERSION=${{ matrix.scalaVersion }} 152 | platforms: ${{ matrix.platforms }} 153 | push: true 154 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Heiko Seeberger 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Scala and sbt Dockerfile 2 | 3 | This repository provides [Scala](http://www.scala-lang.org) and [sbt](http://www.scala-sbt.org) Docker files and images. 4 | 5 | As we think referencing unstable versions is a bad idea we don't publish a `latest` tag. Our tags consists of three parts: `__`. 6 | 7 | Images are updated daily 8 | 9 | Available JDK base images: 10 | * eclipse-temurin 11 | * graalvm-ce 12 | * amazoncorretto 13 | 14 | ## Where to get images 15 | 16 | The images are published at [Docker Hub](https://hub.docker.com/u/sbtscala) 17 | 18 | For a list of all available tags see https://hub.docker.com/r/sbtscala/scala-sbt/tags 19 | 20 | Older tags are available at: https://hub.docker.com/r/hseeberger/scala-sbt/tags 21 | 22 | ## Installation ## 23 | 24 | 1. Install [Docker](https://www.docker.com) 25 | 2. Pull [automated build](https://hub.docker.com/r/sbtscala/scala-sbt/) from public [Docker Hub Registry](https://registry.hub.docker.com): 26 | ``` 27 | docker pull sbtscala/scala-sbt:eclipse-temurin-17.0.4_1.7.1_3.2.0 28 | ``` 29 | Alternatively, you can build an image from the remote Dockerfile: 30 | ``` 31 | docker build \ 32 | --build-arg BASE_IMAGE_TAG="17.0.4.1_1-jdk" \ 33 | --build-arg SBT_VERSION="1.7.1" \ 34 | --build-arg SCALA_VERSION="3.2.0" \ 35 | --build-arg USER_ID=1001 \ 36 | --build-arg GROUP_ID=1001 \ 37 | -t sbtscala/scala-sbt \ 38 | "github.com/sbt/docker-sbt.git#:eclipse-temurin" 39 | ``` 40 | 41 | ## Usage ## 42 | 43 | ``` 44 | docker run -it --rm sbtscala/scala-sbt:eclipse-temurin-17.0.4_1.7.1_3.2.0 45 | ``` 46 | 47 | ### Alternative commands ### 48 | The container contains `bash`, `scala` and `sbt`. 49 | 50 | ``` 51 | docker run -it --rm sbtscala/scala-sbt:eclipse-temurin-17.0.4_1.7.1_3.2.0 scala 52 | ``` 53 | 54 | ### Non-root ### 55 | The container is prepared to be used with a non-root user called `sbtuser` 56 | 57 | ``` 58 | docker run -it --rm -u sbtuser -w /home/sbtuser sbtscala/scala-sbt:eclipse-temurin-17.0.4_1.7.1_3.2.0 59 | ``` 60 | 61 | ## Contribution policy ## 62 | 63 | Contributions via GitHub pull requests are gladly accepted from their original author. Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so. 64 | 65 | 66 | ## License ## 67 | 68 | This code is open source software licensed under the [Apache 2.0 License]("http://www.apache.org/licenses/LICENSE-2.0.html"). 69 | -------------------------------------------------------------------------------- /amazoncorretto/Dockerfile: -------------------------------------------------------------------------------- 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-al2023} 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 | dnf -y update && \ 24 | dnf -y install tar gzip procps git rpm && \ 25 | rm -rf /var/cache/dnf/* && \ 26 | dnf 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 | 2.*) URL=https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz SCALA_DIR=/usr/share/scala-$SCALA_VERSION ;; \ 39 | *) URL=https://github.com/scala/scala3/releases/download/$SCALA_VERSION/scala3-$SCALA_VERSION.tar.gz SCALA_DIR=/usr/share/scala3-$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 | 2*) echo "println(util.Properties.versionMsg)" > /test/test.scala ;; \ 49 | *) 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 ;; \ 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 --script-version && \ 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"] 91 | -------------------------------------------------------------------------------- /eclipse-temurin/Dockerfile: -------------------------------------------------------------------------------- 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 eclipse-temurin:${BASE_IMAGE_TAG:-11.0.16.1_1-jdk} 10 | 11 | # Env variables 12 | ARG SCALA_VERSION 13 | ENV SCALA_VERSION=${SCALA_VERSION:-2.13.10} 14 | ARG SBT_VERSION 15 | ENV SBT_VERSION=${SBT_VERSION:-1.6.2} 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 dependencies 22 | # curl for downloading sbt and scala 23 | # git and rpm for sbt-native-packager (see https://github.com/sbt/docker-sbt/pull/114) 24 | RUN \ 25 | apt-get update && \ 26 | apt-get install -y curl git rpm && \ 27 | rm -rf /var/lib/apt/lists/* 28 | 29 | # Install sbt 30 | RUN \ 31 | curl -fsL --show-error "https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz" | tar xfz - -C /usr/share && \ 32 | chown -R root:root /usr/share/sbt && \ 33 | chmod -R 755 /usr/share/sbt && \ 34 | ln -s /usr/share/sbt/bin/sbt /usr/local/bin/sbt 35 | 36 | # Install Scala 37 | RUN \ 38 | case $SCALA_VERSION in \ 39 | 2.*) URL=https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz SCALA_DIR=/usr/share/scala-$SCALA_VERSION ;; \ 40 | *) URL=https://github.com/scala/scala3/releases/download/$SCALA_VERSION/scala3-$SCALA_VERSION.tar.gz SCALA_DIR=/usr/share/scala3-$SCALA_VERSION ;; \ 41 | esac && \ 42 | curl -fsL --show-error $URL | tar xfz - -C /usr/share/ && \ 43 | mv $SCALA_DIR /usr/share/scala && \ 44 | chown -R root:root /usr/share/scala && \ 45 | chmod -R 755 /usr/share/scala && \ 46 | ln -s /usr/share/scala/bin/* /usr/local/bin && \ 47 | mkdir -p /test && \ 48 | case $SCALA_VERSION in \ 49 | 2*) echo "println(util.Properties.versionMsg)" > /test/test.scala ;; \ 50 | *) 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 ;; \ 51 | esac && \ 52 | scala -nocompdaemon test/test.scala && \ 53 | rm -fr test 54 | 55 | # Symlink java to have it available on sbtuser's PATH 56 | RUN ln -s /opt/java/openjdk/bin/java /usr/local/bin/java 57 | 58 | # Add and use user sbtuser 59 | RUN groupadd --gid $GROUP_ID sbtuser && useradd -m --gid $GROUP_ID --uid $USER_ID sbtuser --shell /bin/bash 60 | USER sbtuser 61 | 62 | # Switch working directory 63 | WORKDIR /home/sbtuser 64 | 65 | # Prepare sbt (warm cache) 66 | RUN \ 67 | sbt --script-version && \ 68 | mkdir -p project && \ 69 | echo "scalaVersion := \"${SCALA_VERSION}\"" > build.sbt && \ 70 | echo "sbt.version=${SBT_VERSION}" > project/build.properties && \ 71 | echo "// force sbt compiler-bridge download" > project/Dependencies.scala && \ 72 | echo "case object Temp" > Temp.scala && \ 73 | sbt compile && \ 74 | rm -r project && rm build.sbt && rm Temp.scala && rm -r target 75 | 76 | # Link everything into root as well 77 | # This allows users of this container to choose, whether they want to run the container as sbtuser (non-root) or as root 78 | USER root 79 | RUN \ 80 | rm -rf /tmp/..?* /tmp/.[!.]* * && \ 81 | ln -s /home/sbtuser/.cache /root/.cache && \ 82 | ln -s /home/sbtuser/.sbt /root/.sbt && \ 83 | if [ -d "/home/sbtuser/.ivy2" ]; then ln -s /home/sbtuser/.ivy2 /root/.ivy2; fi 84 | 85 | # Switch working directory back to root 86 | ## Users wanting to use this container as non-root should combine the two following arguments 87 | ## -u sbtuser 88 | ## -w /home/sbtuser 89 | WORKDIR /root 90 | 91 | CMD ["sbt"] 92 | -------------------------------------------------------------------------------- /eclipse-temurin/alpine.Dockerfile: -------------------------------------------------------------------------------- 1 | # Use a multi-stage build to reduce the size of the final image 2 | # The builder will install curl, bc and ca-certificates which are needed to install sbt and scala. 3 | # The final image will only contain bash, git, rpm, sbt and scala. 4 | 5 | ARG BASE_IMAGE_TAG 6 | FROM eclipse-temurin:${BASE_IMAGE_TAG:-21.0.2_13-jdk-alpine} AS builder 7 | 8 | ARG SCALA_VERSION=3.4.0 9 | ARG SBT_VERSION=1.10.7 10 | ARG USER_ID=1001 11 | ARG GROUP_ID=1001 12 | ENV SCALA_HOME=/usr/share/scala 13 | 14 | # Install dependencies 15 | RUN apk add wget ca-certificates bash curl bc 16 | 17 | # Update certificates, still needed? 18 | RUN update-ca-certificates 19 | 20 | # Install sbt 21 | RUN \ 22 | curl -fsL --show-error https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz | tar xfz - -C /usr/local && \ 23 | ln -s /usr/local/sbt/bin/* /usr/local/bin/ && \ 24 | sbt --script-version 25 | 26 | # Install scala 27 | RUN \ 28 | cd "/tmp" && \ 29 | case $SCALA_VERSION in \ 30 | 2.*) URL=https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz SCALA_DIR=/usr/share/scala-$SCALA_VERSION ;; \ 31 | *) URL=https://github.com/scala/scala3/releases/download/$SCALA_VERSION/scala3-$SCALA_VERSION.tar.gz SCALA_DIR=/usr/share/scala3-$SCALA_VERSION ;; \ 32 | esac && \ 33 | curl -fsL --show-error $URL | tar xfz - -C /usr/share && \ 34 | mv $SCALA_DIR $SCALA_HOME && \ 35 | ln -s "$SCALA_HOME/bin/"* "/usr/bin/" && \ 36 | scala -version && \ 37 | case $SCALA_VERSION in \ 38 | 2*) echo "println(util.Properties.versionMsg)" > test.scala ;; \ 39 | *) 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.scala ;; \ 40 | esac && \ 41 | scala -nocompdaemon test.scala && rm test.scala 42 | 43 | # Start a new stage for the final image 44 | FROM eclipse-temurin:${BASE_IMAGE_TAG:-21.0.2_13-jdk-alpine} 45 | 46 | ARG SCALA_VERSION=3.4.0 47 | ARG SBT_VERSION=1.9.9 48 | ARG USER_ID=1001 49 | ARG GROUP_ID=1001 50 | 51 | RUN apk add --no-cache bash git rpm 52 | 53 | COPY --from=builder /usr/share/scala /usr/share/scala 54 | COPY --from=builder /usr/local/sbt /usr/local/sbt 55 | COPY --from=builder /usr/local/bin/sbt /usr/local/bin/sbt 56 | 57 | # Add and use user sbtuser 58 | RUN addgroup -g $GROUP_ID sbtuser && adduser -D -u $USER_ID -G sbtuser sbtuser 59 | USER sbtuser 60 | 61 | # Switch working directory 62 | WORKDIR /home/sbtuser 63 | 64 | ENV PATH="/usr/share/scala/bin:${PATH}" 65 | 66 | # Prepare sbt (warm cache) 67 | RUN \ 68 | sbt --script-version && \ 69 | mkdir -p project && \ 70 | echo "scalaVersion := \"${SCALA_VERSION}\"" > build.sbt && \ 71 | echo "sbt.version=${SBT_VERSION}" > project/build.properties && \ 72 | echo "// force sbt compiler-bridge download" > project/Dependencies.scala && \ 73 | echo "case object Temp" > Temp.scala && \ 74 | sbt sbtVersion && \ 75 | sbt compile && \ 76 | rm -r project && rm build.sbt && rm Temp.scala && rm -r target 77 | 78 | # Link everything into root as well 79 | # This allows users of this container to choose, whether they want to run the container as sbtuser (non-root) or as root 80 | USER root 81 | RUN \ 82 | rm -rf /tmp/..?* /tmp/.[!.]* * && \ 83 | ln -s /home/sbtuser/.cache /root/.cache && \ 84 | ln -s /home/sbtuser/.sbt /root/.sbt && \ 85 | if [ -d "/home/sbtuser/.ivy2" ]; then ln -s /home/sbtuser/.ivy2 /root/.ivy2; fi 86 | 87 | # Switch working directory back to root 88 | ## Users wanting to use this container as non-root should combine the two following arguments 89 | ## -u sbtuser 90 | ## -w /home/sbtuser 91 | WORKDIR /root 92 | 93 | CMD ["sbt"] 94 | -------------------------------------------------------------------------------- /graalvm-ce/Dockerfile: -------------------------------------------------------------------------------- 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 ghcr.io/graalvm/graalvm-ce:${BASE_IMAGE_TAG:-java11-21.3.0} 10 | 11 | # Env variables 12 | ARG SCALA_VERSION 13 | ENV SCALA_VERSION=${SCALA_VERSION:-2.13.10} 14 | ARG SBT_VERSION 15 | ENV SBT_VERSION=${SBT_VERSION:-1.6.2} 16 | ENV JAVA_OPTS=-XX:+UseG1GC 17 | ARG USER_ID 18 | ENV USER_ID=${USER_ID:-1001} 19 | ARG GROUP_ID 20 | ENV GROUP_ID=${GROUP_ID:-1001} 21 | 22 | # Install dependencies 23 | # ps for scala3 https://github.com/VirtusLab/scala-cli/issues/3130 24 | # git and rpm for sbt-native-packager (see https://github.com/sbt/docker-sbt/pull/114) 25 | RUN \ 26 | microdnf -y install procps git rpm && \ 27 | rm -rf /var/cache/dnf/* && \ 28 | microdnf clean all 29 | 30 | # Install sbt 31 | RUN \ 32 | curl -fsL --show-error "https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz" | tar xfz - -C /usr/share && \ 33 | chown -R root:root /usr/share/sbt && \ 34 | chmod -R 755 /usr/share/sbt && \ 35 | ln -s /usr/share/sbt/bin/sbt /usr/local/bin/sbt 36 | 37 | # Install Scala 38 | RUN \ 39 | case $SCALA_VERSION in \ 40 | 2.*) URL=https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz SCALA_DIR=/usr/share/scala-$SCALA_VERSION ;; \ 41 | *) URL=https://github.com/scala/scala3/releases/download/$SCALA_VERSION/scala3-$SCALA_VERSION.tar.gz SCALA_DIR=/usr/share/scala3-$SCALA_VERSION ;; \ 42 | esac && \ 43 | curl -fsL --show-error $URL | tar xfz - -C /usr/share && \ 44 | mv $SCALA_DIR /usr/share/scala && \ 45 | chown -R root:root /usr/share/scala && \ 46 | chmod -R 755 /usr/share/scala && \ 47 | ln -s /usr/share/scala/bin/* /usr/local/bin && \ 48 | case $SCALA_VERSION in \ 49 | 2*) echo "println(util.Properties.versionMsg)" > test.scala ;; \ 50 | *) 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.scala ;; \ 51 | esac && \ 52 | scala -nocompdaemon test.scala && rm test.scala 53 | 54 | # Add and use user sbtuser 55 | RUN groupadd --gid $GROUP_ID sbtuser && useradd --gid $GROUP_ID --uid $USER_ID sbtuser --shell /bin/bash 56 | USER sbtuser 57 | 58 | # Switch working directory 59 | WORKDIR /home/sbtuser 60 | 61 | # Prepare sbt (warm cache) 62 | RUN \ 63 | sbt --script-version && \ 64 | mkdir -p project && \ 65 | echo "scalaVersion := \"${SCALA_VERSION}\"" > build.sbt && \ 66 | echo "sbt.version=${SBT_VERSION}" > project/build.properties && \ 67 | echo "// force sbt compiler-bridge download" > project/Dependencies.scala && \ 68 | echo "case object Temp" > Temp.scala && \ 69 | sbt compile && \ 70 | rm -r project && rm build.sbt && rm Temp.scala && rm -r target 71 | 72 | # Link everything into root as well 73 | # This allows users of this container to choose, whether they want to run the container as sbtuser (non-root) or as root 74 | USER root 75 | RUN \ 76 | rm -rf /tmp/..?* /tmp/.[!.]* * && \ 77 | ln -s /home/sbtuser/.cache /root/.cache && \ 78 | ln -s /home/sbtuser/.sbt /root/.sbt && \ 79 | if [ -d "/home/sbtuser/.ivy2" ]; then ln -s /home/sbtuser/.ivy2 /root/.ivy2; fi 80 | 81 | # Switch working directory back to root 82 | ## Users wanting to use this container as non-root should combine the two following arguments 83 | ## -u sbtuser 84 | ## -w /home/sbtuser 85 | WORKDIR /root 86 | 87 | CMD ["sbt"] 88 | -------------------------------------------------------------------------------- /graalvm-community/Dockerfile: -------------------------------------------------------------------------------- 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 ghcr.io/graalvm/graalvm-community:${BASE_IMAGE_TAG:-21.0.1-ol9} 10 | 11 | # Env variables 12 | ARG SCALA_VERSION 13 | ENV SCALA_VERSION=${SCALA_VERSION:-2.13.12} 14 | ARG SBT_VERSION 15 | ENV SBT_VERSION=${SBT_VERSION:-1.9.7} 16 | ENV JAVA_OPTS=-XX:+UseG1GC 17 | ARG USER_ID 18 | ENV USER_ID=${USER_ID:-1001} 19 | ARG GROUP_ID 20 | ENV GROUP_ID=${GROUP_ID:-1001} 21 | 22 | # Install dependencies 23 | # ps for scala3 https://github.com/VirtusLab/scala-cli/issues/3130 24 | # git and rpm for sbt-native-packager (see https://github.com/sbt/docker-sbt/pull/114) 25 | RUN \ 26 | microdnf -y install procps git rpm && \ 27 | rm -rf /var/cache/dnf/* && \ 28 | microdnf clean all 29 | 30 | # Install sbt 31 | RUN \ 32 | curl -fsL --show-error "https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz" | tar xfz - -C /usr/share && \ 33 | chown -R root:root /usr/share/sbt && \ 34 | chmod -R 755 /usr/share/sbt && \ 35 | ln -s /usr/share/sbt/bin/sbt /usr/local/bin/sbt 36 | 37 | # Install Scala 38 | RUN \ 39 | case $SCALA_VERSION in \ 40 | 2.*) URL=https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz SCALA_DIR=/usr/share/scala-$SCALA_VERSION ;; \ 41 | *) URL=https://github.com/scala/scala3/releases/download/$SCALA_VERSION/scala3-$SCALA_VERSION.tar.gz SCALA_DIR=/usr/share/scala3-$SCALA_VERSION ;; \ 42 | esac && \ 43 | curl -fsL --show-error $URL | tar xfz - -C /usr/share && \ 44 | mv $SCALA_DIR /usr/share/scala && \ 45 | chown -R root:root /usr/share/scala && \ 46 | chmod -R 755 /usr/share/scala && \ 47 | ln -s /usr/share/scala/bin/* /usr/local/bin && \ 48 | case $SCALA_VERSION in \ 49 | 2*) echo "println(util.Properties.versionMsg)" > test.scala ;; \ 50 | *) 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.scala ;; \ 51 | esac && \ 52 | scala -nocompdaemon test.scala && rm test.scala 53 | 54 | # Add and use user sbtuser 55 | RUN groupadd --gid $GROUP_ID sbtuser && useradd --gid $GROUP_ID --uid $USER_ID sbtuser --shell /bin/bash 56 | USER sbtuser 57 | 58 | # Switch working directory 59 | WORKDIR /home/sbtuser 60 | 61 | # Prepare sbt (warm cache) 62 | RUN \ 63 | sbt --script-version && \ 64 | mkdir -p project && \ 65 | echo "scalaVersion := \"${SCALA_VERSION}\"" > build.sbt && \ 66 | echo "sbt.version=${SBT_VERSION}" > project/build.properties && \ 67 | echo "// force sbt compiler-bridge download" > project/Dependencies.scala && \ 68 | echo "case object Temp" > Temp.scala && \ 69 | sbt compile && \ 70 | rm -r project && rm build.sbt && rm Temp.scala && rm -r target 71 | 72 | # Link everything into root as well 73 | # This allows users of this container to choose, whether they want to run the container as sbtuser (non-root) or as root 74 | USER root 75 | RUN \ 76 | rm -rf /tmp/..?* /tmp/.[!.]* * && \ 77 | ln -s /home/sbtuser/.cache /root/.cache && \ 78 | ln -s /home/sbtuser/.sbt /root/.sbt && \ 79 | if [ -d "/home/sbtuser/.ivy2" ]; then ln -s /home/sbtuser/.ivy2 /root/.ivy2; fi 80 | 81 | # Switch working directory back to root 82 | ## Users wanting to use this container as non-root should combine the two following arguments 83 | ## -u sbtuser 84 | ## -w /home/sbtuser 85 | WORKDIR /root 86 | 87 | CMD ["sbt"] 88 | --------------------------------------------------------------------------------