Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.2.2] docker:publishLocal only succeeds with JavaAppPackaging plugin but not with DockerPlugin #1030

Closed
el-dom opened this issue Sep 7, 2017 · 1 comment

Comments

@el-dom
Copy link

el-dom commented Sep 7, 2017

Expected behaviour

sbt docker:publishLocal should work with DockerPlugin

Actual behaviour

sbt docker:publishLocal only works with JavaAppPackaging

Information

I've started a new project on sbt 1.0.1 (used sbt new sbt/scala-seed.g8 for setup) and added sbt-native-packager 1.2.2 as a plugin. Then i tried to create a docker image out of it using the DockerPlugin like described here.

build.sbt looks like this

lazy val commonSettings = List(
  organization := "de.test",
  scalaVersion := "2.12.3",
  version := "0.1.0-SNAPSHOT"
)

lazy val notifier = (project in file("modules/notifier")).settings(
  commonSettings,
  name := "abandonedcartnotifier",
  libraryDependencies ++= Seq(
    scalaTest % Test,
    akkaHttp,
    circe
  ),
  cancelable := true,
  fork in run := true
)
.settings(dockerSettings(9000): _*)
.enablePlugins(DockerPlugin)

lazy val migrations = (project in file("modules/migrations"))
  .settings(
    commonSettings,
  name := "migrations",
  libraryDependencies ++= Seq(
    flyway,
    postgresJdbc
  )
)

def dockerSettings(port: Int) = {
  Seq(
    dockerBaseImage := s"${sys.props.getOrElse("baseimagetag", default = "")}",
    dockerRepository := None,
    version in Docker := "current-build",
    dockerExposedPorts := Seq(port),
    dockerCommands ++= Seq(Cmd("USER", "daemon"))
  )
}

Trying to publish it with sbt -Dbaseimagetag="test/base:20170802-111029-9-b694b9" docker:publishLocal the build however fails everytime because of a missing opt folder

2:00:44 [info] Removing intermediate container 2c942763c2d9
22:00:44 [info] Step 4 : ADD opt /opt
22:00:44 [error] lstat opt: no such file or directory
22:00:44 [error] java.lang.RuntimeException: Nonzero exit value: 1
22:00:44 [error] 	at com.typesafe.sbt.packager.docker.DockerPlugin$.publishLocalDocker(DockerPlugin.scala:321)
22:00:44 [error] 	at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$24(DockerPlugin.scala:117)
22:00:44 [error] 	at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$24$adapted(DockerPlugin.scala:115)
22:00:44 [error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:44)
22:00:44 [error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:42)
22:00:44 [error] 	at sbt.std.Transform$$anon$4.work(System.scala:64)
22:00:44 [error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:257)
22:00:44 [error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
22:00:44 [error] 	at sbt.Execute.work(Execute.scala:266)
22:00:44 [error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:257)
22:00:44 [error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:167)
22:00:44 [error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:32)
22:00:44 [error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
22:00:44 [error] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
22:00:44 [error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
22:00:44 [error] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
22:00:44 [error] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
22:00:44 [error] 	at java.lang.Thread.run(Thread.java:748)
22:00:44 [error] (notifier/docker:publishLocal) Nonzero exit value: 1

Changing .enablePlugins(DockerPlugin) in build.sbt to .enablePlugins(JavaAppPackaging) creates the docker image successfully.

Am i doing something wrong?

@muuki88
Copy link
Contributor

muuki88 commented Sep 7, 2017

Nope ;)

This is the intended behaviour as documented in the Readme.md and in the core concepts documentation

Separation of concerns of the two plugin kinds

  • format plugins define how a package is created
  • archetype plugins define what a package should contain

@muuki88 muuki88 closed this as completed Sep 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants