gpt4 book ai didi

docker - 使用 docker sbt 在多模块项目中未指定用于发布的存储库

转载 作者:行者123 更新时间:2023-12-02 08:57:26 29 4
gpt4 key购买 nike

我正在尝试使用 sbt-docker 插件部署多模块项目。我想为 api 和应用程序模块创建单独的容器并跳过其他模块。但是,每次我运行 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 的建议,我将非常感激!

最佳答案

我的猜测是,您的子项目 appapi 有两个不同的问题:

1) 在 app 中,您似乎缺少 publishTo 设置。我希望有一个,按照official SBT docs .

2) 在api中,有一个publishTo,但它是在.settings(dockerfile in docker := {...}) block 中定义的 因此该值不会返回/分配给您的子项目的设置。尝试从那里提取它并明确设置,例如.settings(publishTo := Some(Resolver.file("Unused instantrepository"...))) 就像您对 root 项目所做的那样。

希望有帮助!

关于docker - 使用 docker sbt 在多模块项目中未指定用于发布的存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48626415/

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