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

Add: dockerAdditionalVersions #806

Closed
wants to merge 2 commits into from
Closed

Add: dockerAdditionalVersions #806

wants to merge 2 commits into from

Conversation

dgilling
Copy link

Useful if you want other version tags added to Docker Image in addition
to the project version. Examples include tagging by the git hash or git
branch using the sbt-git plugin

dgilling added 2 commits June 10, 2016 13:20
Useful if you want other version tags added to Docker Image in addition
to the project version. Examples include tagging by the git hash or git
branch using the sbt-git plugin
@lightbend-cla-validator

Hi @dgilling,

Thank you for your contribution! We really value the time you've taken to put this together.

Before we proceed with reviewing this pull request, please sign the Typesafe Contributors License Agreement:

http://www.lightbend.com/contribute/cla

@muuki88 muuki88 added the docker label Jun 19, 2016
@muuki88
Copy link
Contributor

muuki88 commented Jun 19, 2016

Thanks for your pull request. Can you add documentation and tests for this feature?

If I understand this correctly, this will publish multiple docker images with different versions in the form of

packageName:tag:version

@dgilling
Copy link
Author

Yes that is correct.

For my workflow, I use it in combination with sbt-git to add a docker tag that is the branch name.
This allows me to reference an image by the normal version tag and also by :develop if for example the git branch was named “develop"

I will add some docs soon and get the paper signed.

Derric

On Jun 19, 2016, at 1:58 PM, Nepomuk Seiler [email protected] wrote:

Thanks for your pull request. Can you add documentation and tests for this feature?

If I understand this correctly, this will publish multiple docker images with different versions in the form of

packageName:tag:version


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub #806 (comment), or mute the thread https://github.com/notifications/unsubscribe/AJCXpieN7rgn8L56clrkG-dFTEaPOR7Gks5qNa1rgaJpZM4IzpJu.

@muuki88
Copy link
Contributor

muuki88 commented Jun 26, 2016

Hi. I had some time to read through the docker stuff and native-packagers implementation.
IMHO a setting dockerAdditionalVersions is the wrong name and definition here. Currently the tag under which name the image gets published is defined here

dockerTarget <<= (dockerRepository, packageName, version) map {
   (repo, name, version) => repo.map(_ + "/").getOrElse("") + name + ":" + version
}

The publishLocal method uses this dockerTarget ( incorrectly scoped to in Docker ) as the tag

publishLocal <<= (stage, dockerTarget, dockerUpdateLatest, streams) { ... }

This results in a docker build command like this

docker build --force-rm -t ${dockerTarget}
# dockerTarget expanded
docker build --force-rm -t [${dockerRepository}/]${packageName}:${version}
# actual command (if dockerRepository is none)
docker build --force-rm -t my-app:0.1.0

The thing dockerAdditionalVersions actually should do is add more -t flags ( actually I would prefer using --tag=, which is easier to read.

Proposal

Instead of introducing a very specific setting dockerAdditionalVersions, which runs the build multiple times. I would rather implement a generic dockerBuildOptions: TaskSetting[Seq[String]] and a more specific dockerTags: TaskSetting[Seq[DockerTag]] setting.

dockerBuildOptions := Seq("--force-rm"),
dockerBuildOptions += dockerTags.value.map { tag => s"--tag=${tag.asBuildOption}" }
dockerBuildOptions ++= if(dockerLatest.value) { /* add latest tag */ } else Seq.empty
...

def publishLocalDocker(context: File, options: Seq[String], log: Logger) {
   val cmd = Seq("docker", "build") ++ options ++ Seq(".")
   // ...
}

which would create a general abstraction for the build options.

The DockerTag could look like this

case class DockerTag(name: String, version: Option[String]) {
   def asBuildOption: String = name + version.map(v => s":$v"}.getOrElse("")
}

@fiadliel WDYT?

@dgilling
Copy link
Author

Sorry about the delay.

Document is signed.
With reduced file size to avoid Email Reject.

On Jun 19, 2016, at 3:02 PM, Derric Gilling [email protected] wrote:

Yes that is correct.

For my workflow, I use it in combination with sbt-git to add a docker tag that is the branch name.
This allows me to reference an image by the normal version tag and also by :develop if for example the git branch was named “develop"

I will add some docs soon and get the paper signed.

Derric

On Jun 19, 2016, at 1:58 PM, Nepomuk Seiler <[email protected] mailto:[email protected]> wrote:

Thanks for your pull request. Can you add documentation and tests for this feature?

If I understand this correctly, this will publish multiple docker images with different versions in the form of

packageName:tag:version


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub #806 (comment), or mute the thread https://github.com/notifications/unsubscribe/AJCXpieN7rgn8L56clrkG-dFTEaPOR7Gks5qNa1rgaJpZM4IzpJu.

@muuki88
Copy link
Contributor

muuki88 commented Jul 22, 2016

Hi @dgilling . There is going to be another contribution, implementing the suggested solution above. I would close this pull request in favor of the more generic solution.

@muuki88
Copy link
Contributor

muuki88 commented Aug 4, 2016

closing in favor of #854

@muuki88 muuki88 closed this Aug 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants