Skip to content

Commit 631f809

Browse files
authored
fix(Docker.*?Plugin): restore the sbt-standard task concurrency tags (#1352)
"restore"-ish: sbt defines Publish and Network on both publish & publishLocal, we replace Network by Disk on publishLocal to reflect the DockerPlugin's actual resource usage
1 parent 07d7b84 commit 631f809

2 files changed

Lines changed: 51 additions & 40 deletions

File tree

src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,10 @@ object DockerPlugin extends AutoPlugin {
233233

234234
stage0 ++ stage1
235235
}
236-
) ++ mapGenericFilesToDocker ++ inConfig(Docker)(
237-
Seq(
238-
executableScriptName := executableScriptName.value,
239-
mappings ++= dockerPackageMappings.value,
240-
name := name.value,
241-
packageName := packageName.value,
242-
publishLocal := {
236+
) ++ mapGenericFilesToDocker ++ inConfig(Docker)({
237+
238+
def publishLocalTask =
239+
Def.task {
243240
val log = streams.value.log
244241
publishLocalDocker(
245242
stage.value,
@@ -252,25 +249,37 @@ object DockerPlugin extends AutoPlugin {
252249
log.info(
253250
s"Built image ${dockerAlias.value.withTag(None).toString} with tags [${dockerAliases.value.flatMap(_.tag).mkString(", ")}]"
254251
)
255-
},
256-
publish := {
252+
} tag (Tags.Disk, Tags.Publish)
253+
254+
def publishTask =
255+
Def.task {
257256
val _ = publishLocal.value
258257
val alias = dockerAliases.value
259258
val log = streams.value.log
260259
val execCommand = dockerExecCommand.value
261260
alias.foreach { aliasValue =>
262261
publishDocker(execCommand, aliasValue.toString, log)
263262
}
264-
},
265-
clean := {
266-
val alias = dockerAliases.value
267-
val log = streams.value.log
268-
val rmiCommand = dockerRmiCommand.value
269-
// clean up images
270-
alias.foreach { aliasValue =>
271-
rmiDocker(rmiCommand, aliasValue.toString, log)
272-
}
273-
},
263+
} tag (Tags.Network, Tags.Publish)
264+
265+
def cleanTask = Def.task {
266+
val alias = dockerAliases.value
267+
val log = streams.value.log
268+
val rmiCommand = dockerRmiCommand.value
269+
// clean up images
270+
alias.foreach { aliasValue =>
271+
rmiDocker(rmiCommand, aliasValue.toString, log)
272+
}
273+
}
274+
275+
Seq(
276+
executableScriptName := executableScriptName.value,
277+
mappings ++= dockerPackageMappings.value,
278+
name := name.value,
279+
packageName := packageName.value,
280+
publishLocal := publishLocalTask.value,
281+
publish := publishTask.value,
282+
clean := cleanTask.value,
274283
sourceDirectory := sourceDirectory.value / "docker",
275284
stage := Stager.stage(Docker.name)(streams.value, stagingDirectory.value, dockerLayerMappings.value.map {
276285
case LayeredMapping(layerIdx, file, path) => (file, pathInLayer(path, layerIdx))
@@ -308,7 +317,7 @@ object DockerPlugin extends AutoPlugin {
308317
generateDockerConfig(dockerCommands.value, stagingDirectory.value)
309318
}
310319
)
311-
)
320+
})
312321

313322
/**
314323
* @param comment

src/main/scala/com/typesafe/sbt/packager/docker/DockerSpotifyClientPlugin.scala

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,28 @@ object DockerSpotifyClientPlugin extends AutoPlugin {
6060
dockerApiVersion := dockerServerApiVersion.value
6161
)
6262

63-
def publishLocalDocker: Def.Initialize[Task[Unit]] = Def.task {
64-
val context = stage.value
65-
val primaryAlias = dockerAlias.value
66-
val aliases = dockerAliases.value
67-
val log = streams.value.log
68-
69-
val dockerDirectory = context.toString
70-
71-
val docker = new DockerClientTask()
72-
docker.packageDocker(primaryAlias, aliases, dockerDirectory, log)
73-
}
74-
75-
def publishDocker: Def.Initialize[Task[Unit]] = Def.task {
76-
val _ = publishLocal.value
77-
val aliases = dockerAliases.value
78-
val log = streams.value.log
79-
80-
val docker = new DockerClientTask()
81-
docker.publishDocker(aliases, log)
82-
}
63+
def publishLocalDocker: Def.Initialize[Task[Unit]] =
64+
Def.task {
65+
val context = stage.value
66+
val primaryAlias = dockerAlias.value
67+
val aliases = dockerAliases.value
68+
val log = streams.value.log
69+
70+
val dockerDirectory = context.toString
71+
72+
val docker = new DockerClientTask()
73+
docker.packageDocker(primaryAlias, aliases, dockerDirectory, log)
74+
} tag (Tags.Publish, Tags.Disk)
75+
76+
def publishDocker: Def.Initialize[Task[Unit]] =
77+
Def.task {
78+
val _ = publishLocal.value
79+
val aliases = dockerAliases.value
80+
val log = streams.value.log
81+
82+
val docker = new DockerClientTask()
83+
docker.publishDocker(aliases, log)
84+
} tag (Tags.Network, Tags.Publish)
8385

8486
def dockerServerVersion: Def.Initialize[Task[Option[DockerVersion]]] = Def.task {
8587
val docker = new DockerClientTask()

0 commit comments

Comments
 (0)