On this page
Build a Scala Native app in Alpine 🔗
Use a multi-stage Docker build when you want Deder to run in Alpine and ship a small image containing only the Scala Native executable.
-
Install Alpine's clang and GCC packages in the build stage:
FROM eclipse-temurin:21-jdk-alpine AS build RUN apk add --no-cache clang gcc curlTemurin provides the JDK 21 required by Deder's server.
gccsuppliescrtbeginS.o,libgcc, andlibgcc_s, which Scala Native's link step requires on Alpine. -
Run Deder from
deder-client.jar:RUN java -jar /opt/deder/deder-client.jar exec \ --log-level warning \ --no-color \ -t nativeLink \ -m appThe released native Deder client is glibc-linked, so use the JAR client in the Alpine build stage. Deder reads the server version from the active
amendsURL indeder.pkl, then downloads the matching server and test-runner artifacts. -
Copy the linked executable into the runtime stage:
FROM alpine:3.23 COPY --from=build /src/.deder/out/app/nativeLink/app /usr/local/bin/app ENTRYPOINT ["app"]
The Scala Native example Dockerfile combines these stages for the cli module:
cd examples/scalanative
docker build -t deder-scalanative-example .
docker run --rm deder-scalanative-example
The example uses the version from its deder.pkl config URL by default. To override both the client and server versions, set DEDER_VERSION. The Dockerfile then writes that version to .deder/server.properties:
docker build \
--build-arg DEDER_VERSION=v0.22.2 \
-t deder-scalanative-example .
The final image in this example is approximately 15 MB. If your application uses additional native libraries, install those libraries in the runtime stage as well.