liveBook · Manning

DockerPlugin

As explained in Akka in Action, Second Edition

DockerPlugin is an sbt-native-packager format plugin that builds a project artifact as a Docker image.

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

How Akka in Action, Second Edition covers it

How deep it goes
Explains plugin roles, image settings, build commands, and repository publication, but defers Dockerfile internals.
Examples
Uses minimal Akka clustering configuration and a multi-port betting-house deployment as concrete Docker image examples.
What it assumes
Assumes an sbt project with an executable application and introduces the required packaging plugins and Docker settings.
What you can do after
Build it from scratch with sbt, configure its runtime image and ports, publish it locally, and deploy the image through Kubernetes.
How it connects
Connects DockerPlugin with sbt-native-packager, JavaAppPackaging, Docker images, Akka Management, Akka Remote, and Kubernetes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Akka in Action, Second Edition. The section links point to the parts of the book it draws on.