我试图将这个令人敬畏的Scala应用程序部署为Docker容器。 https://github.com/OlegIlyenko/graphql-toolbox
它使用sbt构建系统。我尝试使用这个Dockerfile在容器中运行sbt。 https://gist.github.com/rzachariah/77eb927f650347ef06d0009dc220cd4a
容器构建并启动,但随后立即退出。
我猜sbt run
是一个互动过程 - 而不是一个守护进程。对容器中的sbt run
可能是一个坏主意。
我开始研究sbt-assembly来创建一个我可以执行的胖罐。 https://github.com/sbt/sbt-assembly
当我sbt assembly
时,我遇到了一些错误。
C:\Users\rzachariah\.ivy2\cache\commons-logging\commons-logging\jars\commons-logging-1.1.1.jar:org/apache/commons/logging/impl/SimpleLog.class
at sbtassembly.Assembly$.applyStrategies(Assembly.scala:140)
at sbtassembly.Assembly$.x$1$lzycompute$1(Assembly.scala:25)
at sbtassembly.Assembly$.x$1$1(Assembly.scala:23)
at sbtassembly.Assembly$.stratMapping$lzycompute$1(Assembly.scala:23)
at sbtassembly.Assembly$.stratMapping$1(Assembly.scala:23)
at sbtassembly.Assembly$.inputs$lzycompute$1(Assembly.scala:67)
at sbtassembly.Assembly$.inputs$1(Assembly.scala:57)
at sbtassembly.Assembly$.apply(Assembly.scala:83)
at sbtassembly.Assembly$$anonfun$assemblyTask$1.apply(Assembly.scala:240)
at sbtassembly.Assembly$$anonfun$assemblyTask$1.apply(Assembly.scala:237)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[error] (*:assembly) deduplicate: different file contents found in the following:
[error] C:\Users\rzachariah\.ivy2\cache\io.netty\netty-handler\jars\netty-handler-4.0.36.Final.jar:META-INF/io.netty.versions.properties
[error] C:\Users\rzachariah\.ivy2\cache\io.netty\netty-buffer\jars\netty-buffer-4.0.36.Final.jar:META-INF/io.netty.versions.properties
[error] C:\Users\rzachariah\.ivy2\cache\io.netty\netty-common\jars\netty-common-4.0.36.Final.jar:META-INF/io.netty.versions.properties
[error] C:\Users\rzachariah\.ivy2\cache\io.netty\netty-transport\jars\netty-transport-4.0.36.Final.jar:META-INF/io.netty.versions.properties
[error] C:\Users\rzachariah\.ivy2\cache\io.netty\netty-codec\jars\netty-codec-4.0.36.Final.jar:META-INF/io.netty.versions.properties
[error] C:\Users\rzachariah\.ivy2\cache\io.netty\netty-codec-http\jars\netty-codec-http-4.0.36.Final.jar:META-INF/io.netty.versions.properties
[error] C:\Users\rzachariah\.ivy2\cache\io.netty\netty-transport-native-epoll\jars\netty-transport-native-epoll-4.0.36.Final-linux-x86_64.jar:META-INF/io.netty.versions.properties
[error] deduplicate: different file contents found in the following:
[error] C:\Users\rzachariah\.ivy2\cache\org.slf4j\jcl-over-slf4j\jars\jcl-over-slf4j-1.7.19.jar:org/apache/commons/logging/Log.class
[error] C:\Users\rzachariah\.ivy2\cache\commons-logging\commons-logging\jars\commons-logging-1.1.1.jar:org/apache/commons/logging/Log.class
[error] deduplicate: different file contents found in the following:
[error] C:\Users\rzachariah\.ivy2\cache\org.slf4j\jcl-over-slf4j\jars\jcl-over-slf4j-1.7.19.jar:org/apache/commons/logging/LogConfigurationException.class
[error] C:\Users\rzachariah\.ivy2\cache\commons-logging\commons-logging\jars\commons-logging-1.1.1.jar:org/apache/commons/logging/LogConfigurationException.class
[error] deduplicate: different file contents found in the following:
[error] C:\Users\rzachariah\.ivy2\cache\org.slf4j\jcl-over-slf4j\jars\jcl-over-slf4j-1.7.19.jar:org/apache/commons/logging/LogFactory.class
[error] C:\Users\rzachariah\.ivy2\cache\commons-logging\commons-logging\jars\commons-logging-1.1.1.jar:org/apache/commons/logging/LogFactory.class
[error] deduplicate: different file contents found in the following:
[error] C:\Users\rzachariah\.ivy2\cache\org.slf4j\jcl-over-slf4j\jars\jcl-over-slf4j-1.7.19.jar:org/apache/commons/logging/impl/NoOpLog.class
[error] C:\Users\rzachariah\.ivy2\cache\commons-logging\commons-logging\jars\commons-logging-1.1.1.jar:org/apache/commons/logging/impl/NoOpLog.class
[error] deduplicate: different file contents found in the following:
[error] C:\Users\rzachariah\.ivy2\cache\org.slf4j\jcl-over-slf4j\jars\jcl-over-slf4j-1.7.19.jar:org/apache/commons/logging/impl/SimpleLog$1.class
[error] C:\Users\rzachariah\.ivy2\cache\commons-logging\commons-logging\jars\commons-logging-1.1.1.jar:org/apache/commons/logging/impl/SimpleLog$1.class
[error] deduplicate: different file contents found in the following:
[error] C:\Users\rzachariah\.ivy2\cache\org.slf4j\jcl-over-slf4j\jars\jcl-over-slf4j-1.7.19.jar:org/apache/commons/logging/impl/SimpleLog.class
[error] C:\Users\rzachariah\.ivy2\cache\commons-logging\commons-logging\jars\commons-logging-1.1.1.jar:org/apache/commons/logging/impl/SimpleLog.class
[error] Total time: 5 s, completed Oct 10, 2016 6:41:44 PM
我认为我需要定义合并策略,但我对如何做到这一点感到有些困惑。有什么指针吗?我是斯卡拉新手。
答案 0 :(得分:0)
我了解到,由于我的scala应用程序使用了play框架,并且内置了本机打包器,因此将我的应用程序打包到容器中非常简单!
sbt docker:publishLocal
http://www.scala-sbt.org/sbt-native-packager/formats/docker.html