Hi Southin,
Now I will go into specifics on how to get Play working with all this: (This assumes you are using Play 2.4.x, if you are not please let me know as there are some minor changes)
1. Go into your project/plugins.sbt file and make sure to add the following line:
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3")
Where 1.0.3 is whatever version of the Sbt native packager you are using.
2. Open up your build.sbt file:
2.1 Make sure you have enablePlugins with SbtNativePackager and DockerPlugin enabled at minimum. Here is an example of my build.sbt
lazy val root = (project in file(".")).enablePlugins(PlayJava,SbtNativePackager,DockerPlugin,SbtWeb)
Note that you probably don't need all of these enabled, for instance SbtWeb is for a different sbt plugin. Just make sure you have SbtNativePackager and DockerPlugin.
2.2
At minimum have the following fields filled out in your build.sbt:
//Docker.io setup
// setting a maintainer which is used for all packaging types
maintainer := "Southin"
// exposing the play ports (Change these to whatever you are using)
dockerExposedPorts in Docker := Seq(9000, 9443)
dockerBaseImage := "dockerfile/java:oracle-java8"
dockerRepository := Some("www.pathtoyour/dockerregistry")
Now to actually build and deploy your application you will need Linux since Docker support really isn't solid for Windows yet (AFAIK) Assuming on Linux, type the following commands:
./activator clean update compile docker:publish
alternatively, if you just want to publish locally and not deploy to your docker registry server you can type:
./activator clean update compile docker:publishLocal
If you are curious as to what is actually happening, you can go into the target/docker directory. You should see a Dockerfile and a stage directory.
The rest of what I say below should not be necessary as SBT should build and push your Docker app to your registry directly. But if you do want to have a little more control or just understand a few extra commands, continue reading:
At this point if you wanted to you could manually build and deploy your docker app through docker itself:
docker build -t www.pathtoyour/dockerregistry/project-name stage
(Stage is the name of the directory that has your actual files in it. Feel free to look around to understand how everything is working. playapppath/target/docker/stage)
docker push www.pathtoyour/dockerregistry/project-name
That's the basic idea of how to deploy Play applications through Docker. Please let me know if you have any questions.
Thanks,
-Sean