0

I'm trying to add sbt-docker to my sbt build of my play website but I'm running into an issue. For some reason none of the docker related stuff on the bottom can resolve.

project/plugins.sbt

logLevel := Level.Warn

resolvers ++= Seq(
    "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
)

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.9")

build.sbt

name := "personal_site"

version := "1.1"

lazy val `personal_site` = (project in file(".")).enablePlugins(PlayScala,DockerPlugin)

scalaVersion := "2.11.7"

libraryDependencies ++= Seq( jdbc , cache , ws , specs2 % Test )

unmanagedResourceDirectories in Test <+=  baseDirectory ( _ /"target/web/public/test" )  

resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"

dockerfile in docker := {
    val targetDir = "/usr/src"

    new Dockerfile {
        from("flurdy/activator")
        //More goes here
    }
}

imageNames in docker := Seq(
    // Sets the latest tag
    ImageName(s"${name.value}:latest"),

    // Sets a name with a tag that contains the project version
    ImageName(
        namespace = None,
        repository = name.value,
        tag = Some("v" + version.value)
    )
)

Here's an image of what it looks like in IntelliJ

enter image description here

I've also tried adding addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.4.0") to my project/plugins.sbt but I get this error about DockerPlugin being imported twice.

~/Sync/Projects/Programming/Personal_Site (master ✘)✹ ᐅ  sbt clean
[info] Loading project definition from /home/ryan/Sync/Projects/Programming/Personal_Site/project
/home/ryan/Sync/Projects/Programming/Personal_Site/build.sbt:5: error: reference to DockerPlugin is ambiguous;
it is imported twice in the same scope by
import _root_.sbtdocker.DockerPlugin
and import _root_.com.typesafe.sbt.packager.docker.DockerPlugin
lazy val `personal_site` = (project in file(".")).enablePlugins(PlayScala,DockerPlugin)
4

1 回答 1

1

Try changing your build.sbt config to this.

lazy val root = (project in file(".")).enablePlugins(sbtdocker.DockerPlugin, PlayScala)

It removes the ambiguity by using the full name to DockerPlugin, since sbt-native-packager uses the same name for its Docker plugin I believe.

Maybe worth raising a Github issue with the author's repo so they can document it in the project docs.

于 2016-11-30T15:15:27.140 回答