我正在尝试使用sbt-docker插件部署多模块项目。我想为api和app模块创建单独的容器并跳过其他模块。但是,每次运行docker: publish
时都会出现这样的错误:
[error] (api/*:publishConfiguration) Repository for publishing is not specified.
[error] (app/*:publishConfiguration) Repository for publishing is not specified.
这是我的build.sbt文件:
import sbt.Keys.publishTo
name := "project-name"
val globalSettings = Seq[SettingsDefinition](
version := "1.0",
scalaVersion := "2.12.4"
)
enablePlugins(DockerPlugin)
//.. other modules
val app = Project("app", file("app"))
.enablePlugins(DockerPlugin)
.dependsOn(repositories)
.settings(globalSettings: _*)
.settings(
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-http" % "10.0.11",
"com.typesafe.akka" %% "akka-http-testkit" % "10.0.11" % Test,
"de.heikoseeberger" %% "akka-http-circe" % "1.18.0",
"net.ruippeixotog" %% "scala-scraper" % "2.1.0"
),
resolvers += Resolver.bintrayRepo("hseeberger", "maven")
)
.settings(assemblyJarName in assembly := "app.jar")
.settings(dockerfile in docker := {
val artifact: File = assembly.value
val artifactTargetPath = s"/app/${artifact.name}"
new Dockerfile {
from("java")
add(artifact, artifactTargetPath)
entryPoint("java", "-jar", artifactTargetPath)
}
},
imageNames in docker := Seq(ImageName(s"name/dru-app"))
)
val api = Project("api", file("api"))
.enablePlugins(DockerPlugin)
.dependsOn(app)
.settings(globalSettings: _*)
.settings(
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-http" % "10.0.11",
"com.typesafe.akka" %% "akka-http-testkit" % "10.0.11" % Test,
"de.heikoseeberger" %% "akka-http-circe" % "1.18.0",
"net.ruippeixotog" %% "scala-scraper" % "2.1.0"
),
resolvers += Resolver.bintrayRepo("hseeberger", "maven")
)
.settings(assemblyJarName in assembly := "api.jar")
.settings(dockerfile in docker := {
val artifact: File = assembly.value
val artifactTargetPath = s"/api/${artifact.name}"
publishTo := Some(Resolver.file("Unused transient repository", file("https://hub.docker.com/r/name/dru-api")))
new Dockerfile {
from("java")
add(artifact, artifactTargetPath)
entryPoint("java", "-jar", artifactTargetPath)
}
},
imageNames in docker := Seq(ImageName(s"name/dru-api"))
)
val root = Project("DRU-W3-FP-1-Toloka-Parser", file("."))
.aggregate(app, api)
.settings(
publish := {},
publishLocal := {},
publishArtifact := false,
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))
)
我非常感谢有关如何修复build.sbt文件以将其发布到docker hub的任何建议!
答案 0 :(得分:0)
我的猜测是子项目app
和api
遇到两个不同的问题:
1)在app
中,您似乎缺少了publishTo
设置。根据{{3}},我希望有一个。
2)在api
中,有一个publishTo
,但它是在块.settings(dockerfile in docker := {...})
中定义的,因此该值不会返回/未分配给子项目的设置。尝试从那里提取它并进行显式设置,例如.settings(publishTo := Some(Resolver.file("Unused transient repository"...)))
就像您在root
项目中所做的那样。
希望有帮助!