gpt4 book ai didi

docker - 在docker中运行的akka​​-http应用程序

转载 作者:行者123 更新时间:2023-12-02 20:15:43 25 4
gpt4 key购买 nike

我有一个在本地可以正常运行的akka​​-http应用程序,在“docker化”该应用程序时遇到一些问题。我通过Dockerfile并使用docker-entrypoint来执行java -jar命令来构建docker镜像。当我第一次访问正在运行的docker容器时,该应用程序未运行,尽管如果我访问该容器并手动执行java -jar命令,则该应用程序会正常运行。如果我在容器内执行以下命令,应用程序也会正常启动:

bash -xe docker-entrypoint.sh

见下面我的Dockerfile
FROM qa.stratio.com/stratio/ubuntu-base:16.04

MAINTAINER stratio

ARG VERSION

RUN apt-get update && apt-get install -y screen

COPY target/khermes-${VERSION}-allinone.jar /khermes.jar
COPY docker/docker-entrypoint.sh /
COPY src/main/resources/application.conf /

EXPOSE 8080

ENTRYPOINT ["/docker-entrypoint.sh"]

并在我的docker-entrypoint.sh下面也看到:
#!/bin/bash -xe

java -jar -Dkhermes.client=false -Dakka.remote.hostname=localhost -
Dakka.remote.netty.tcp.port=2553 -Dakka.cluster.seed-
nodes.0=akka.tcp://khermes@localhost:2552 /khermes.jar

tail -f /dev/null

有谁知道为什么在运行容器时我的应用程序被杀死?

最佳答案

我建议改为使用SBT Native Packager。我的build.scala看起来像这样

import com.typesafe.sbt.packager.archetypes.JavaAppPackaging
import com.typesafe.sbt.packager.docker.{Cmd, DockerPlugin}
import com.typesafe.sbt.packager.docker.DockerPlugin.autoImport._
import sbt._
import Keys._

object build extends Build {

lazy val root: Project = Project(
id = "my-awesome-server",
base = file("."),
settings = Defaults.coreDefaultSettings ++ Seq(

resolvers ++= {
Seq(
"sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
},

organization := "co.awesome-startup",
version := "2.69",
scalaVersion := "2.11.8",
libraryDependencies ++= {
Seq(
"org.tpolecat" %% "atto-core" % "0.4.2" withSources()
)
},
dockerBaseImage := "expert/docker-java-minimal:server-jre",
dockerCommands := dockerCommands.value.flatMap {
case cmd@Cmd("FROM", _) => List(cmd, Cmd("RUN", "apk update && apk add bash"))
case other => List(other)
},
dockerRepository := Some("awesome-startup"),
version in Docker := version.value,

scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8", "-language:implicitConversions", "-language:postfixOps", "-language:higherKinds", "-Xcheckinit"), //, "-Xlog-implicits"),
javaOptions in compile += "-g:source,lines,vars",
crossPaths := false,
mainClass in Compile := Some("co.awesome-startup.server.EntryPoint")
)
).enablePlugins(JavaAppPackaging).
enablePlugins(DockerPlugin)
}

您需要更改项目名称和 dockerRepository以匹配Docker Hub中的存储库,然后可以通过调用 sbt docker:publish来构建和部署它。如果要在本地发布Docker镜像,请调用 sbt docker:publishLocal

关于docker - 在docker中运行的akka​​-http应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43558057/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com