Skip to content

Instantly share code, notes, and snippets.

@cjwebb
Created August 25, 2018 19:28
Show Gist options
  • Save cjwebb/990521180022e6080525c745061553d3 to your computer and use it in GitHub Desktop.
Save cjwebb/990521180022e6080525c745061553d3 to your computer and use it in GitHub Desktop.
Scala SBT dockerfile - runs SBT to build, and then copies on the jar to the alpine java image
# This uses the Docker builder pattern.
# The first container runs SBT to stage our application.
# todo - use a Docker image that has already downloaded SBT
FROM hseeberger/scala-sbt AS builder
WORKDIR /app
COPY src src
COPY project project
COPY build.sbt build.sbt
RUN sbt stage
# The second takes the generated jars and scripts from the first, and places them in a minimal JRE container.
# Therefore, we don't have to run a container with SBT inside it. It is much smaller.
FROM openjdk:jre-alpine
COPY --from=builder --chown=daemon:daemon /app/target/universal/stage /opt
USER daemon
ENTRYPOINT ["/opt/bin/allez"]
CMD []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment