Created
August 4, 2020 01:43
-
-
Save dnatic09/0d2248afceedb3b2b5115e31c0c5e3e0 to your computer and use it in GitHub Desktop.
Example Dockerfile showing how to use multiple stages to build a Scala project
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
# First stage, SBT, identifer named `builder` | |
FROM mozilla/sbt:8u232_1.3.13 AS builder | |
# ADD all source | |
ADD . / | |
# Run SBT assembly, if tests fail, the docker image will not build | |
RUN sbt assembly | |
# Second stage, OpenJDK for JVM runtime | |
FROM adoptopenjdk/openjdk11:jdk-11.0.7_10-debian-slim | |
# COPY the jar built in the first stage into this stage, I am intentionally removing the version from the JAR filename | |
COPY --from=builder ./target/scala-2.12/multistagedocker-assembly-*jar /multistagedocker.jar | |
# Set ENTRYPOINT to uberjar | |
ENTRYPOINT ["java", "-jar", "/multistagedocker.jar"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment