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 Docker labels easily #962

Merged
merged 4 commits into from
Apr 13, 2017
Merged

Add Docker labels easily #962

merged 4 commits into from
Apr 13, 2017

Conversation

NeQuissimus
Copy link
Contributor

This change allows for an easy way to add labels to Docker images.
It was previously possible to add this as custom commands but given the importance of labels, it seems reasonable to make adding them more easily.

I believe there is not much documentation necessary. I added a reference to the settings key.

As an example, we will be using this to forward Jenkins job variables into our Docker images.

dockerLabels := Map(
  "BUILD" -> sys.env.getOrElse("BUILD_NUMBER", "local"),
  "GIT_COMMIT" -> sys.env.getOrElse("GIT_COMMIT", "local")
)

Copy link
Contributor

@muuki88 muuki88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your pull request. Feature and implementation look solid to me.

Could you add a small test, setting some labels that ensure that the docker command still runs?

You can find the tests here:
https://github.com/sbt/sbt-native-packager/tree/master/src/sbt-test/docker

You can find some docs on how to run the tests in the Developer Guide

Also +1 for the documentation :)

makeExposePorts(dockerExposedPorts.value, dockerExposedUdpPorts.value) ++
makeVolumes(dockerExposedVolumes.value, user, group) ++
Seq(makeUser(user), makeEntrypoint(dockerEntrypoint.value), makeCmd(dockerCmd.value))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like formatting changes. When you run sbt scalafmt it should format correctly.
Or if you use intellij along with the scalafmt plugin you may use a newer or older version.

@NeQuissimus
Copy link
Contributor Author

I had forgotten about a test :)

I ran scalafmt against everything, seems there were a few files it was unhappy with...

@muuki88
Copy link
Contributor

muuki88 commented Apr 13, 2017

Thanks a lot :)

@muuki88 muuki88 merged commit 3b1adc4 into sbt:master Apr 13, 2017
@NeQuissimus NeQuissimus deleted the docker_labels branch April 13, 2017 16:19
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.

2 participants