The author Jacek Laskowski has nearly 20 years of experience in application development, and is now a codilime software development team Leader, who has obtained many certifications from IBM. In this blog post, Jacek shares a Docker SBT plugin introduced by Rafal Krzewski on Warsaw Scala enthusiasts Meetup. This article is compiled by OneAPM engineers:
Although Docker has been used in a very deep application in the Deepsense.io project, it has not been exposed to the Rafal Krzewski one of the two Docker SBT plugins shared on Warsaw Scala enthusiasts Meetup. --sbt-native-packager (the other is Sbt-docker), I'm still not aware that deploying a Scala WEB application can be as simple as that.
This article will focus on how easy it is to deploy a Play Framework-based Scala Web application using Docker, which is based primarily on the Sbt-native-packager plugin.
Build a Play-Framework Web-based application
Use the Typesafe Activator tool activator new to create a new WEB application using the command:
Use cd the command play-dockerized to enter the directory and execute the sbt run command to start the application:
By this point, http://localhost:9000 has been able to be visited. As you can see, this is a WEB application based on the Play Framework 2.4.2.
Publish Docker Image--docker:publishlocal
Because you want to use the Sbt-native-packager plug-in, you need to use Ctrl+d to end the previous command and execute the sbt docker:publishLocal command:
Here, I believe a lot of people have seen the smart Sbt-native-packager plug-in design, it is very clever to use the publishLocal task to publish one Docker repository .
In the previous step, a brand new Docker image Play-dockerized:1.0-snapshot was created, where you can use Docker images to view its properties.
Docker time!
You can use docker run commands to play-dockerized open a container outside.
docker runThe alternative to the command is -p to use it to discover Docker ports outside the virtual network 9000 (local available ports are 8080 ), and to use – name for container-friendly naming instead of the default hash naming method.
In another terminal Docker PS to see how the container is running:
docker stop play-8080to terminate this container. This based Play Framework application will not be accessible. If you restart, you can execute the docker start play-8080 command.
Summarize
It's so easy to build a Docker image for a Scala Web application based on the Play Framework, and I'm sure many people will be able to do it like I do. Once you convert an application to Docker image, you can use other commands, and you can also throw away the application's dependency on the environment.
original link : Docker Your Scala Web application (Play Framework)
This article is compiled and collated by OneAPM engineers. OneAPM is an emerging leader in application performance management, enabling enterprise users and developers to easily implement slow program code and real-time crawling of SQL statements. To read more technical articles, please visit the OneAPM official blog.
How do I deploy a Play Framework-based Scala Web app using Docker?