scalatra + docker (part 1)
Here’s a github repo which will track this project
–
I really enjoyed writing my posts about containerizing an Nginx web service. So I thought it would be fun to do something a little more advanced and “Dockerize” a Scalatra web server. In this first post we will just get the basic Hello World app built with Scalatra.
–
Part 1: Basic Web Server
“In accordance with the ancient traditions of our people, we must first build an app that does nothing except say Hello world.” -Facebook’s React Native tutorial
Using Scalatra, we can get a web server up and running quickly, similar to other minimal frameworks like Ruby’s Sinatra or JavaScript’s Express.
Download Dependencies (OS X specific):
Let’s use Giter8 which provides a quick wizard to bootstrap an app. Here’s the labels I provided:
Now we can start the sbt
cli, compile and run our code.
There will be a TON of output as sbt downloads dependencies and builds the project. When you see Server:main: Started
, hit http://localhost:8080
in the browser and you’ll see the standard Scalatra welcome screen.
In the next post we will add JSON support to our server, getting it ready to field requests from our Nginx frontend container.