Skip to content

Commit

Permalink
Merge pull request #68 from yuvipanda/print-dockerfile
Browse files Browse the repository at this point in the history
Add --debug & --no-build options
  • Loading branch information
yuvipanda committed Sep 6, 2017
2 parents 30d7fd1 + d116c30 commit 8db1d43
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions repo2docker/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ def get_argparser(self):
help='Push docker image to repository'
)

argparser.add_argument(
'--debug',
help="Turn on debug logging",
action='store_true',
)

argparser.add_argument(
'--no-run',
dest='run',
Expand All @@ -158,6 +164,13 @@ def get_argparser(self):
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='*',
Expand All @@ -169,6 +182,9 @@ def get_argparser(self):
def initialize(self):
args = self.get_argparser().parse_args()

if args.debug:
self.log_level = logging.DEBUG

self.load_config_file(args.config)

if os.path.exists(args.repo):
Expand Down Expand Up @@ -210,6 +226,12 @@ def initialize(self):
self.run = args.run
self.json_logs = args.json_logs

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


Expand Down Expand Up @@ -296,17 +318,20 @@ def start(self):
picked_buildpack = bp
break

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:
self.log.info(l['stream'], extra=dict(phase='building'))
elif 'error' in l:
self.log.info(l['error'], extra=dict(phase='failure'))
sys.exit(1)
elif 'status' in l:
self.log.info('Fetching base image...\r', extra=dict(phase='building'))
else:
self.log.info(json.dumps(l), extra=dict(phase='building'))
self.log.debug(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:
self.log.info(l['stream'], extra=dict(phase='building'))
elif 'error' in l:
self.log.info(l['error'], extra=dict(phase='failure'))
sys.exit(1)
elif 'status' in l:
self.log.info('Fetching base image...\r', extra=dict(phase='building'))
else:
self.log.info(json.dumps(l), extra=dict(phase='building'))

if self.cleanup_checkout:
shutil.rmtree(checkout_path)
Expand Down

0 comments on commit 8db1d43

Please sign in to comment.