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

fix(Docker.*?Plugin): restore the sbt-standard task concurrency tags #1352

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 29 additions & 20 deletions src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -252,25 +249,37 @@ 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
val execCommand = dockerExecCommand.value
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))
Expand Down Expand Up @@ -308,7 +317,7 @@ object DockerPlugin extends AutoPlugin {
generateDockerConfig(dockerCommands.value, stagingDirectory.value)
}
)
)
})

/**
* @param comment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down