diff --git a/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala index 216c49b3a..39126180e 100644 --- a/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala @@ -233,13 +233,10 @@ object DockerPlugin extends AutoPlugin { stage0 ++ stage1 } - ) ++ mapGenericFilesToDocker ++ inConfig(Docker)( - Seq( - executableScriptName := executableScriptName.value, - mappings ++= dockerPackageMappings.value, - name := name.value, - packageName := packageName.value, - publishLocal := { + ) ++ mapGenericFilesToDocker ++ inConfig(Docker)({ + + def publishLocalTask = + Def.task { val log = streams.value.log publishLocalDocker( stage.value, @@ -252,8 +249,10 @@ object DockerPlugin extends AutoPlugin { log.info( s"Built image ${dockerAlias.value.withTag(None).toString} with tags [${dockerAliases.value.flatMap(_.tag).mkString(", ")}]" ) - }, - publish := { + } tag (Tags.Disk, Tags.Publish) + + def publishTask = + Def.task { val _ = publishLocal.value val alias = dockerAliases.value val log = streams.value.log @@ -261,16 +260,26 @@ object DockerPlugin extends AutoPlugin { alias.foreach { aliasValue => publishDocker(execCommand, aliasValue.toString, log) } - }, - clean := { - val alias = dockerAliases.value - val log = streams.value.log - val rmiCommand = dockerRmiCommand.value - // clean up images - alias.foreach { aliasValue => - rmiDocker(rmiCommand, aliasValue.toString, log) - } - }, + } tag (Tags.Network, Tags.Publish) + + def cleanTask = Def.task { + val alias = dockerAliases.value + val log = streams.value.log + val rmiCommand = dockerRmiCommand.value + // clean up images + alias.foreach { aliasValue => + rmiDocker(rmiCommand, aliasValue.toString, log) + } + } + + Seq( + executableScriptName := executableScriptName.value, + mappings ++= dockerPackageMappings.value, + name := name.value, + packageName := packageName.value, + publishLocal := publishLocalTask.value, + publish := publishTask.value, + clean := cleanTask.value, sourceDirectory := sourceDirectory.value / "docker", stage := Stager.stage(Docker.name)(streams.value, stagingDirectory.value, dockerLayerMappings.value.map { case LayeredMapping(layerIdx, file, path) => (file, pathInLayer(path, layerIdx)) @@ -308,7 +317,7 @@ object DockerPlugin extends AutoPlugin { generateDockerConfig(dockerCommands.value, stagingDirectory.value) } ) - ) + }) /** * @param comment diff --git a/src/main/scala/com/typesafe/sbt/packager/docker/DockerSpotifyClientPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/docker/DockerSpotifyClientPlugin.scala index 727dbbf99..a5d406a55 100644 --- a/src/main/scala/com/typesafe/sbt/packager/docker/DockerSpotifyClientPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/docker/DockerSpotifyClientPlugin.scala @@ -60,26 +60,28 @@ object DockerSpotifyClientPlugin extends AutoPlugin { dockerApiVersion := dockerServerApiVersion.value ) - def publishLocalDocker: Def.Initialize[Task[Unit]] = Def.task { - val context = stage.value - val primaryAlias = dockerAlias.value - val aliases = dockerAliases.value - val log = streams.value.log - - val dockerDirectory = context.toString - - val docker = new DockerClientTask() - docker.packageDocker(primaryAlias, aliases, dockerDirectory, log) - } - - def publishDocker: Def.Initialize[Task[Unit]] = Def.task { - val _ = publishLocal.value - val aliases = dockerAliases.value - val log = streams.value.log - - val docker = new DockerClientTask() - docker.publishDocker(aliases, log) - } + def publishLocalDocker: Def.Initialize[Task[Unit]] = + Def.task { + val context = stage.value + val primaryAlias = dockerAlias.value + val aliases = dockerAliases.value + val log = streams.value.log + + val dockerDirectory = context.toString + + val docker = new DockerClientTask() + docker.packageDocker(primaryAlias, aliases, dockerDirectory, log) + } tag (Tags.Publish, Tags.Disk) + + def publishDocker: Def.Initialize[Task[Unit]] = + Def.task { + val _ = publishLocal.value + val aliases = dockerAliases.value + val log = streams.value.log + + val docker = new DockerClientTask() + docker.publishDocker(aliases, log) + } tag (Tags.Network, Tags.Publish) def dockerServerVersion: Def.Initialize[Task[Option[DockerVersion]]] = Def.task { val docker = new DockerClientTask()