-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69895e5
commit 21812a7
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,30 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- | ||
name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: rubixcubin/scala-graal-builder:latest |
This file contains 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,29 @@ | ||
FROM debian:11-slim | ||
|
||
# Artifact information | ||
ARG sdkmanGraalJavaVersion="22.0.0.2.r17-grl" | ||
|
||
# User information | ||
ARG username="builder" | ||
ARG useruid=1000 | ||
ARG groupid=1000 | ||
ARG groupname="buildergroup" | ||
ARG home="/home/$username" | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
# Add a non-root user and specify dependencies needed for SDKMAN and GraalVM native image | ||
RUN groupadd -g $groupid $username && \ | ||
useradd -m -g $groupid -u $useruid $username && \ | ||
apt-get update && \ | ||
apt-get install -y curl zip build-essential libz-dev zlib1g-dev | ||
|
||
# Switch to the user | ||
USER $useruid:$groupid | ||
|
||
# Install SDKMAN | ||
RUN curl -s "https://get.sdkman.io" | bash && \ | ||
source $home/.sdkman/bin/sdkman-init.sh && \ | ||
sdk install java $sdkmanGraalJavaVersion && \ | ||
sdk install sbt && \ | ||
gu install native-image |
This file contains 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,33 @@ | ||
# A Docker image to build Scala & Graal Native Image projects | ||
|
||
This image relies on SDKMAN to provide the following: | ||
* The latest version of SBT at the time of building | ||
* A GraalVM CE flavour of the JVM (currently `22.0.0.2.r17`) | ||
* Graal Native Image to build native image binaries. | ||
|
||
|
||
## Building locally | ||
|
||
1. `docker build -t rubixcubin/scala-graal-builder:local .` | ||
2. `docker run -it rubixcubin/scala-graal-builder:local bash` | ||
|
||
|
||
## Recommended usage | ||
You can use a multi-stage build if you want to use this image to build your project | ||
and leverage the artifacts produced by the build in a smaller image to package and serve your application. | ||
|
||
For example, for a native-image build: | ||
```Dockerfile | ||
# Step 1: Use this image to build your project | ||
FROM rubixcubin/scala-graal-builder:latest as builder | ||
COPY . /build | ||
WORKDIR /build | ||
|
||
# This generates the binary that represents your application | ||
RUN sbt graalvm-native-image:packageBin | ||
|
||
# This is what you want to use to package and run your application | ||
FROM gcr.io/distroless/base | ||
COPY --from=builder /build/your-project/target/graalvm-native-image /app | ||
CMD ["/app/your-app"] | ||
``` |