mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Merge pull request #850 from progrium/mh-test-deploy-scala
test scala deployment
This commit is contained in:
2
Vagrantfile
vendored
2
Vagrantfile
vendored
@@ -3,7 +3,7 @@
|
||||
|
||||
BOX_NAME = ENV["BOX_NAME"] || "trusty"
|
||||
BOX_URI = ENV["BOX_URI"] || "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
|
||||
BOX_MEMORY = ENV["BOX_MEMORY"] || "512"
|
||||
BOX_MEMORY = ENV["BOX_MEMORY"] || "1024"
|
||||
DOKKU_DOMAIN = ENV["DOKKU_DOMAIN"] || "dokku.me"
|
||||
DOKKU_IP = ENV["DOKKU_IP"] || "10.0.0.2"
|
||||
PREBUILT_STACK_URL = File.exist?("#{File.dirname(__FILE__)}/stack.tgz") ? 'file:///root/dokku/stack.tgz' : nil
|
||||
|
||||
5
tests.mk
5
tests.mk
@@ -93,6 +93,10 @@ deploy-test-python-flask:
|
||||
@echo deploying python-flask app...
|
||||
cd tests && ./test_deploy ./apps/python-flask dokku.me
|
||||
|
||||
deploy-test-scala:
|
||||
@echo deploying scala app...
|
||||
cd tests && ./test_deploy ./apps/scala dokku.me
|
||||
|
||||
deploy-test-static:
|
||||
@echo deploying static app...
|
||||
cd tests && ./test_deploy ./apps/static dokku.me
|
||||
@@ -111,6 +115,7 @@ deploy-tests:
|
||||
@$(QUIET) $(MAKE) deploy-test-nodejs-express
|
||||
@$(QUIET) $(MAKE) deploy-test-php
|
||||
@$(QUIET) $(MAKE) deploy-test-python-flask
|
||||
@$(QUIET) $(MAKE) deploy-test-scala
|
||||
@$(QUIET) $(MAKE) deploy-test-static
|
||||
|
||||
test: setup-deploy-tests lint unit-tests deploy-tests
|
||||
|
||||
21
tests/apps/scala/LICENSE
Normal file
21
tests/apps/scala/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Joe Kutner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
1
tests/apps/scala/Procfile
Normal file
1
tests/apps/scala/Procfile
Normal file
@@ -0,0 +1 @@
|
||||
web: target/universal/stage/bin/scala-getting-started
|
||||
33
tests/apps/scala/README.md
Normal file
33
tests/apps/scala/README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# scala-getting-started
|
||||
|
||||
A barebones Scala app, which can easily be deployed to Heroku.
|
||||
|
||||
This application support the [Getting Started with Scala on Heroku](https://devcenter.heroku.com/articles/getting-started-with-scala) article - check it out.
|
||||
|
||||
## Running Locally
|
||||
|
||||
Make sure you have Scala and sbt installed. Also, install the [Heroku Toolbelt](https://toolbelt.heroku.com/).
|
||||
|
||||
```sh
|
||||
$ git clone https://github.com/heroku/scala-getting-started.git
|
||||
$ cd scala-getting-started
|
||||
$ sbt compile stage
|
||||
$ foreman start web
|
||||
```
|
||||
|
||||
Your app should now be running on [localhost:5000](http://localhost:5000/).
|
||||
|
||||
## Deploying to Heroku
|
||||
|
||||
```sh
|
||||
$ heroku create
|
||||
$ git push heroku master
|
||||
$ heroku open
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
For more information about using Scala on Heroku, see these Dev Center articles:
|
||||
|
||||
- [Scala on Heroku](https://devcenter.heroku.com/categories/scala)
|
||||
|
||||
14
tests/apps/scala/build.sbt
Normal file
14
tests/apps/scala/build.sbt
Normal file
@@ -0,0 +1,14 @@
|
||||
import NativePackagerKeys._
|
||||
|
||||
packageArchetype.java_application
|
||||
|
||||
name := """scala-getting-started"""
|
||||
|
||||
version := "1.0"
|
||||
|
||||
scalaVersion := "2.10.4"
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"com.twitter" % "finagle-http_2.10" % "6.18.0",
|
||||
"postgresql" % "postgresql" % "9.0-801.jdbc4"
|
||||
)
|
||||
2
tests/apps/scala/check_deploy
Executable file
2
tests/apps/scala/check_deploy
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e; output="$(curl -s -S $1)"; echo $output; test "$output" == "Hello from Scala!"
|
||||
4
tests/apps/scala/project/build.properties
Normal file
4
tests/apps/scala/project/build.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
#Activator-generated Properties
|
||||
#Wed Aug 13 09:36:12 CDT 2014
|
||||
template.uuid=a855816c-0367-44ba-9adb-6a903f6ad599
|
||||
sbt.version=0.13.5
|
||||
1
tests/apps/scala/project/plugins.sbt
Normal file
1
tests/apps/scala/project/plugins.sbt
Normal file
@@ -0,0 +1 @@
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.7.4")
|
||||
65
tests/apps/scala/src/main/scala/com/example/Server.scala
Normal file
65
tests/apps/scala/src/main/scala/com/example/Server.scala
Normal file
@@ -0,0 +1,65 @@
|
||||
package com.example
|
||||
|
||||
import com.twitter.finagle.{Http, Service}
|
||||
import com.twitter.util.{Await, Future}
|
||||
import com.twitter.finagle.http.Response
|
||||
import java.net.InetSocketAddress
|
||||
import org.jboss.netty.handler.codec.http._
|
||||
import util.Properties
|
||||
import java.net.URI
|
||||
import java.sql.Connection
|
||||
import java.sql.DriverManager
|
||||
|
||||
object Server {
|
||||
def main(args: Array[String]) {
|
||||
val port = Properties.envOrElse("PORT", "8080").toInt
|
||||
println("Starting on port: "+port)
|
||||
|
||||
val server = Http.serve(":" + port, new Hello)
|
||||
Await.ready(server)
|
||||
}
|
||||
}
|
||||
|
||||
class Hello extends Service[HttpRequest, HttpResponse] {
|
||||
def apply(request: HttpRequest): Future[HttpResponse] = {
|
||||
if (request.getUri.endsWith("/db")) {
|
||||
showDatabase(request);
|
||||
} else {
|
||||
showHome(request);
|
||||
}
|
||||
}
|
||||
|
||||
def showHome(request: HttpRequest): Future[HttpResponse] = {
|
||||
val response = Response()
|
||||
response.setStatusCode(200)
|
||||
response.setContentString("Hello from Scala!")
|
||||
Future(response)
|
||||
}
|
||||
|
||||
def showDatabase(request: HttpRequest): Future[HttpResponse] = {
|
||||
val connection = getConnection
|
||||
val stmt = connection.createStatement
|
||||
stmt.executeUpdate("CREATE TABLE IF NOT EXISTS ticks (tick timestamp)")
|
||||
stmt.executeUpdate("INSERT INTO ticks VALUES (now())")
|
||||
|
||||
val rs = stmt.executeQuery("SELECT tick FROM ticks")
|
||||
|
||||
var out = ""
|
||||
while (rs.next) {
|
||||
out += "Read from DB: " + rs.getTimestamp("tick") + "\n"
|
||||
}
|
||||
|
||||
val response = Response()
|
||||
response.setStatusCode(200)
|
||||
response.setContentString(out)
|
||||
Future(response)
|
||||
}
|
||||
|
||||
def getConnection(): Connection = {
|
||||
val dbUri = new URI(System.getenv("DATABASE_URL"))
|
||||
val username = dbUri.getUserInfo.split(":")(0)
|
||||
val password = dbUri.getUserInfo.split(":")(1)
|
||||
val dbUrl = "jdbc:postgresql://" + dbUri.getHost + dbUri.getPath
|
||||
DriverManager.getConnection(dbUrl, username, password)
|
||||
}
|
||||
}
|
||||
1
tests/apps/scala/system.properties
Normal file
1
tests/apps/scala/system.properties
Normal file
@@ -0,0 +1 @@
|
||||
java.runtime.version=1.7
|
||||
Reference in New Issue
Block a user