always build image with docker cmd
This commit is contained in:
parent
7dc36feaa3
commit
bd6a026e9c
@ -115,24 +115,15 @@ def build_image(client, conf, update, verbose):
|
|||||||
dockerfile.append(pkginstall.format(p))
|
dockerfile.append(pkginstall.format(p))
|
||||||
try:
|
try:
|
||||||
if verbose:
|
if verbose:
|
||||||
# fallback to external command 'docker build' as there is
|
|
||||||
# no way to follow the build progress with API.
|
|
||||||
print('Building image {} ...'.format(tag))
|
print('Building image {} ...'.format(tag))
|
||||||
cmd = ['docker', 'build']
|
cmd = ['docker', 'build']
|
||||||
if update:
|
if update:
|
||||||
cmd.append('--no-cache')
|
cmd.append('--no-cache')
|
||||||
cmd += ['-t', tag, '-']
|
cmd += ['-t', tag, '-']
|
||||||
ret = subprocess.run(cmd,
|
ret = subprocess.run(cmd,
|
||||||
input='\n'.join(dockerfile).encode('utf-8'),
|
input='\n'.join(dockerfile).encode('utf-8'),
|
||||||
stderr=subprocess.STDOUT, check=True)
|
stderr=subprocess.STDOUT, check=True)
|
||||||
image = client.images.get(tag)
|
image = client.images.get(tag)
|
||||||
else:
|
|
||||||
with io.BytesIO('\n'.join(dockerfile).encode('utf-8')) as fd:
|
|
||||||
image, logs = client.images.build(tag=tag, fileobj=fd, rm=True, nocache=update)
|
|
||||||
if verbose:
|
|
||||||
print('Built image {} / {}'.format(image.tags[0], image.short_id))
|
|
||||||
for l in logs:
|
|
||||||
print(l.get('stream', '').strip('\n'))
|
|
||||||
|
|
||||||
if not os.path.exists(cache_dir):
|
if not os.path.exists(cache_dir):
|
||||||
os.mkdir(cache_dir)
|
os.mkdir(cache_dir)
|
||||||
|
Loading…
Reference in New Issue
Block a user