Add --print-dockerfile & --no-build options
MODIFY
repo2docker/app.py
repo2docker/app.py
@@ -144,6 +144,12 @@ class Repo2Docker(Application):
help='Push docker image to repository'
)
+ argparser.add_argument(
+ '--print-dockerfile',
+ help="Print dockerfile contents to stdout",
+ action='store_true',
+ )
+
argparser.add_argument(
'--no-run',
dest='run',
@@ -158,6 +164,13 @@ class Repo2Docker(Application):
help="Don't clean up remote checkouts after we are done"
)
+ argparser.add_argument(
+ '--no-build',
+ dest='build',
+ action='store_false',
+ help="Do not actually build the image. Useful in conjugation with --print-dockerfile."
+ )
+
argparser.add_argument(
'cmd',
nargs='*',
@@ -210,6 +223,13 @@ class Repo2Docker(Application):
self.run = args.run
self.json_logs = args.json_logs
+ self.print_dockerfile = args.print_dockerfile
+ self.build = args.build
+ if not self.build:
+ # Can't push nor run if we aren't building
+ self.run = False
+ self.push = False
+
self.run_cmd = args.cmd
@@ -296,6 +316,10 @@ class Repo2Docker(Application):
picked_buildpack = bp
break
+ if self.print_dockerfile:
+ self.log.info(picked_buildpack.render(), extra=dict(phase='building'))
+
+ if self.build:
self.log.info('Using %s builder\n', bp.name, extra=dict(phase='building'))
for l in picked_buildpack.build(self.output_image_spec):
if 'stream' in l:

Add --print-dockerfile & --no-build options