Dockerfile.py now live prints docker build output
Signed-off-by: Adam Hill <adam@diginc.us>
This commit is contained in:
parent
a6e70b653d
commit
aa31e6baf6
|
@ -21,7 +21,8 @@ from docopt import docopt
|
|||
from jinja2 import Environment, FileSystemLoader
|
||||
from docopt import docopt
|
||||
import os
|
||||
import testinfra
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
@ -105,10 +106,6 @@ def build_dockerfiles(args):
|
|||
|
||||
|
||||
def build(docker_repo, arch, args):
|
||||
run_local = testinfra.get_backend(
|
||||
"local://"
|
||||
).get_module("Command").run
|
||||
|
||||
dockerfile = 'Dockerfile_{}'.format(arch)
|
||||
repo_tag = '{}:{}_{}'.format(docker_repo, __version__, arch)
|
||||
cached_image = '{}/{}'.format('pihole', repo_tag)
|
||||
|
@ -123,14 +120,14 @@ def build(docker_repo, arch, args):
|
|||
print(" ::: Building {} into {}".format(dockerfile, repo_tag))
|
||||
if args['-v']:
|
||||
print(build_command, '\n')
|
||||
build_result = run_local(build_command)
|
||||
build_result = subprocess.Popen(build_command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
if args['-v']:
|
||||
print(build_result.stdout)
|
||||
print(build_result.stderr)
|
||||
if build_result.rc != 0:
|
||||
for c in iter(lambda: build_result.stdout.read(1), b''): # replace '' with b'' for Python 3
|
||||
sys.stdout.write(c)
|
||||
if build_result.returncode != 0:
|
||||
print(" ::: Building {} encountered an error".format(dockerfile))
|
||||
print(build_result.stderr)
|
||||
assert build_result.rc == 0
|
||||
assert build_result.returncode == 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue