DockerPlugin is an sbt-native-packager format plugin that wraps a packaged application in a Docker image. JavaAppPackaging supplies the application contents and internal structure; DockerPlugin supplies the image’s external structure and parameters such as its base image and exposed ports. section 13.2.1
version := "0.1.0-SNAPSHOT" #1 enablePlugins(JavaAppPackaging, DockerPlugin) #2 dockerExposedPorts := Seq(8558, 2552) #3 dockerBaseImage := "adoptopenjdk:11-jre-hotspot" #4
A minimal build.sbt configuration enables both plugins, exposes Akka ports, and selects an OpenJDK 11 runtime image. section 13.2.1
A typical DockerPlugin workflow is:
- Enable JavaAppPackaging and DockerPlugin in build.sbt. section 13.2.1
- Set the project version, dockerBaseImage, and dockerExposedPorts; provide a main class when the application requires an explicit entry point. section 13.2.1 section 15.3.2
- Build locally with sbt docker:publishLocal, or publish an image with sbt betting-house/docker:publish. section 13.2.1 section 15.3.2
- Tag and push the image to a repository that Kubernetes can reach when local storage is insufficient. section 13.2.1
Packaging a clustered betting application
A betting-house project enables AkkaGrpcPlugin, JavaAppPackaging, and DockerPlugin; exposes ports for Akka Management, Akka Remote, services, and projections; selects adoptopenjdk:11-jre-hotspot; and publishes with sbt betting-house/docker:publish. Kubernetes deployment manifests then refer to the resulting image. section 15.3.2
