6 from emuvim
.api
.util
.path_utils
import get_absolute_path
9 def build_dockerfile_dir(folder
, tag
):
10 dcli
= docker
.from_env().api
11 folder
= get_absolute_path(folder
)
12 build_stream
= dcli
.build(folder
, tag
=tag
)
13 logging
.info('Docker build result:')
14 for line
in build_stream
:
18 def suffix_tag_name(tag
, suffix
):
20 return "%s_%s" % (tag
, suffix
)
21 return "%s:latest_%s" % (tag
, suffix
)
24 def wrap_debian_like(image
):
25 dcli
= docker
.from_env().api
28 RUN apt update -y && apt install -y net-tools iputils-ping iproute
30 f
= BytesIO(dockerfile
.encode('utf-8'))
31 wrapper_name
= suffix_tag_name(image
, 'containernet_compatible')
32 logging
.info('wrapping image: %s->%s' % (image
, wrapper_name
))
33 build_stream
= dcli
.build(fileobj
=f
, tag
=wrapper_name
)
34 build_result
= [line
for line
in build_stream
]
35 logging
.debug('Docker build result:' + '\n'.join(build_result
))
39 # 172.17.0.1 is the ip of the docker0 interface on the host
40 DOCKER_HOST_IP
= '172.17.0.1'