简体   繁体   English

如何在Scala中激活sbt DockerPlugin?

[英]How to activate the sbt DockerPlugin in scala?

I have two scala projects, one is already defined to build its docker container through the sbt docker plugin. 我有两个scala项目,一个已经定义为通过sbt docker插件构建其docker容器。 The other one I want to dockerify as well. 我也想对另一个进行dockerify。

The working one has in its build.sbt the following lines relevant to the docker config: 工作的人在其build.sbt具有与build.sbt config相关的以下行:

organization := "com.namespace"
name := "dockerized-app"
version := sys.env.getOrElse("PIPELINE_VERSION", "0.1.0_local")
scalaVersion := "2.12.4"
enablePlugins(JavaAppPackaging)
enablePlugins(DockerPlugin)
packageName in Docker := packageName.value
dockerRepository := Some("our-docker.io:5001")
dockerExposedPorts := Seq(8080)

I thought that I could copy paste the relevant lines to the new project, change the name, and make it work. 我以为我可以将相关行复制粘贴到新项目中,更改名称并使其工作。

Yet when I add the line to the about to be dockerified scala project: 但是,当我将行添加到即将被dockerified的scala项目中时:

enablePlugins(DockerPlugin)

I get the error: 我得到错误:

 Cannot resolve symbol DockerPlugin

I've looked through the prexisting projects libraryDependencies , yet it doesn't seem to be configured that way. 我已经浏览了先前存在的项目libraryDependencies ,但似乎没有采用这种方式进行配置。 In the the pre-configured project, IntellJ somehow knows the plugin, I can track that the DockerPlugin comes from com.typesafe.sbt.packager.docker . 在预配置的项目中,IntellJ以某种方式知道插件,我可以跟踪DockerPlugin来自com.typesafe.sbt.packager.docker This made me assume that sbt comes shipped with it by default. 这使我假设默认情况下sbt附带了它。

Yet apparently I have to activate it somehow. 但是显然我必须以某种方式激活它。

Digging deeper I also tried adding this to my plugins.sbt to no avail: 深入研究我也尝试将其添加到我的plugins.sbt中无济于事:

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.2")

How to activate DockerPlugin using sbt in scala? 如何在Scala中使用sbt激活DockerPlugin

In order to make it working properly you need to add the following line: 为了使其正常工作,您需要添加以下行:

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.2")

in your project/plugins.sbt file. 在您的project/plugins.sbt文件中。

Then refresh your project and it should work. 然后刷新您的项目,它应该可以工作。

For further information, please check the Sbt Native Packager documentation . 有关更多信息,请查看Sbt Native Packager文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM