Add Dockerfile repo2docker labels
MODIFY
repo2docker/app.py
repo2docker/app.py
@@ -745,6 +745,11 @@ class Repo2Docker(Application):
picked_buildpack = self.default_buildpack()
picked_buildpack.appendix = self.appendix
+ picked_buildpack.labels = {
+ 'repo2docker.version': self.version,
+ 'repo2docker.repo': self.repo,
+ 'repo2docker.ref': self.ref,
+ }
self.log.debug(picked_buildpack.render(),
extra=dict(phase='building'))

MODIFY
repo2docker/buildpacks/base.py
repo2docker/buildpacks/base.py
@@ -120,8 +120,8 @@ ENV {{item[0]}} {{item[1]}}
# Container image Labels!
# Put these at the end, since we don't want to rebuild everything
# when these change! Did I mention I hate Dockerfile cache semantics?
-{% for k, v in labels.items() -%}
-LABEL {{k}}={{v}}
+{% for k, v in labels.items() %}
+LABEL {{k}}="{{v}}"
{%- endfor %}
# We always want containers to run as non-root
@@ -246,7 +246,7 @@ class BuildPack:
"""
Docker labels to set on the built image.
"""
- return {}
+ return getattr(self, 'labels', {})
def get_build_script_files(self):
"""

Add Dockerfile repo2docker labels