Scala and Play framework Docker Image
- Dockerhub: ysihaoy/scala-play
- Docker image for Scala, Play framework and SBT project with different versions
Supported tags (combinations of Scala, Play and SBT) and Dockerfile links
How to use in your Scala SBT project
Choose a image tag, e.g
2.12.3-2.6.2-sbt-0.13.15is highly recommended instead of
Sample of your minimal project structure
your-play-project │ build.sbt │ Dockerfile │ ├───project | build.properties | plugins.sbt | ├───app │ │ ... | └───test
Sample of your
Dockerfileshould be like:
FROM ysihaoy/scala-play:2.12.2-2.6.0-sbt-0.13.15 # caching dependencies COPY ["build.sbt", "/tmp/build/"] COPY ["project/plugins.sbt", "project/build.properties", "/tmp/build/project/"] RUN cd /tmp/build && \ sbt compile && \ sbt test:compile && \ rm -rf /tmp/build # copy code COPY . /root/app/ WORKDIR /root/app RUN sbt compile && sbt test:compile EXPOSE 9000 CMD ["sbt"]
Optimisation of the build time
In order to have fast CI (continuous integration) build process, sample of your
build.sbt should be like:
sbt.version = 0.13.15
// The Play plugin addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.0")
scalaVersion := "2.12.2"
activator was EOL-ed on May 24, 2017, instead of using the Activator command, make sure you have sbt 0.13.13 (or higher), and use the “sbt new” command, providing the name of the template. Click here to see more.
Happy hacking Scala, Play framework and Docker
Thanks for this image,
however I have an issue. Basically
sbt starts and my app will not run.
$ docker logs -f containername [info] Loading project definition from /root/app/project [info] Set current project to ProjectName (in build file:/root/app/)
If I change
CMD ["sbt"] to
CMD ["sbt run"] then the app runs and then immediately stops so the docker container exits.
Please let me know if you have any suggestions?