我想在Jelastic平臺上部署一個使用Play Framework 2.5編寫的應用程序。我設法使用Play2War插件進行Play,但它還不支持Play 2.5。如何在Jelastic上使用Docker部署Play 2.5應用程序?
對平臺的支持建議使用Docker容器或VPS。我以前從未與Docker合作過。有一個SBT native packager plugin提供了一種自動創建帶有SBT的Dockerfile的方法。 因此,這裏是我的新plugins.sbt文件:
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.11")
// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.2")
// Play enhancer - this automatically generates getters/setters for public fields
// and rewrites accessors of these fields to use the getters/setters. Remove this
// plugin if you prefer not to have this feature, or disable on a per project
// basis using disablePlugins(PlayEnhancer) in your build.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")
// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
// enablePlugins(PlayEbean).
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "3.0.0")
// Play Eclipse plugin
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
// Play native packager support for Docker
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0-M8")
這裏是基於一些例子泊塢窗設置我build.sbt文件:
import com.typesafe.sbt.packager.docker._
name := """VestaWeb"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean, DockerPlugin)
scalaVersion := "2.11.7"
// Configure Docker settings
maintainer in Docker := "eeproperty"
dockerRepository := Some("eeproperty")
dockerBaseImage := "frolvlad/alpine-oraclejdk8:latest"
dockerCommands := dockerCommands.value.flatMap {
case [email protected]("FROM", _) => List(cmd, Cmd("RUN", "apk update && apk add bash"))
case other => List(other)
}
// Add dependencies from Maven
libraryDependencies ++= Seq(
filters,
javaCore,
javaJdbc,
cache,
javaWs,
"mysql" % "mysql-connector-java" % "5.1.28",
"com.stripe" % "stripe-java" % "2.10.0",
"com.typesafe.play" %% "play-mailer" % "5.0.0",
"it.innove" % "play2-pdf" % "1.5.1",
"com.google.api-client" % "google-api-client" % "1.22.0",
"org.apache.commons" % "commons-compress" % "1.12"
)
// Remove the documentation from the dist
sources in (Compile, doc) := Seq.empty
publishArtifact in (Compile, packageDoc) := false
// Disable strange behavior in local run
fork in run := false
命令:
activator docker:stage
生成此Dockerfile:
FROM frolvlad/alpine-oraclejdk8:latest
RUN apk update && apk add bash
MAINTAINER eeproperty
WORKDIR /opt/docker
ADD opt /opt
RUN ["chown", "-R", "daemon:daemon", "."]
USER daemon
ENTRYPOINT ["bin/vestaweb"]
CMD []
和其他一些東西,如docker/
文件夾。
命令:
activator docker:publish
出版Dockerfile(也許其他文件???)我多克庫。我不知道Docker推動什麼,以及它如何知道如何將Play應用嵌入到Alpine Linux基礎鏡像中。
我將我的資源庫添加到一個Docker實例和Jelastic,並且我開始了它。我可以通過SSH登錄到我的root帳戶,但與容器中的應用程序沒有任何關係。當我嘗試在瀏覽器中打開Jelastic節點時,什麼都沒有顯示。
默認情況下,Play Framework使用端口80的端口9000和Jelastic負載。我想我不得不添加一個iptables
命令到我的Dockerfile來重定向從80到9000的交通。
我已經閱讀了很多關於「Dockerize Play應用程序」的教程,但他們從未解釋如何部署應用程序,只有如何在本地運行容器與activator docker:publishLocal
。
我錯過了什麼觀點?
是否在本地的碼頭工人的工作和/ opt /文件夾不是空的? – Aless