diff --git a/bentoml/cli/bento_service.py b/bentoml/cli/bento_service.py index 72a06659e1e..469154338eb 100644 --- a/bentoml/cli/bento_service.py +++ b/bentoml/cli/bento_service.py @@ -381,7 +381,7 @@ def containerize(bento, push, tag, build_arg, yatai_url): docker_build_args = {} if build_arg: for arg in build_arg: - key, value = arg.split("=") + key, value = arg.split("=", 1) docker_build_args[key] = value if yatai_url is not None: spinner_message = f'Sending containerize RPC to YataiService at {yatai_url}' diff --git a/bentoml/yatai/yatai_service_impl.py b/bentoml/yatai/yatai_service_impl.py index d20db7bdf0a..2eafa9b65c6 100644 --- a/bentoml/yatai/yatai_service_impl.py +++ b/bentoml/yatai/yatai_service_impl.py @@ -500,7 +500,9 @@ def ContainerizeBento(self, request, context=None): safe_retrieve(bento_service_bundle_path, temp_bundle_path) try: docker_client.images.build( - path=temp_bundle_path, tag=tag, buildargs=request.build_args + path=temp_bundle_path, + tag=tag, + buildargs=dict(request.build_args), ) except (docker.errors.APIError, docker.errors.BuildError) as error: logger.error(f'Encounter container building issue: {error}') diff --git a/tests/integration/yatai_server/test_containerize.py b/tests/integration/yatai_server/test_containerize.py index fa789a15457..f1f0faead89 100644 --- a/tests/integration/yatai_server/test_containerize.py +++ b/tests/integration/yatai_server/test_containerize.py @@ -1,4 +1,5 @@ import logging +import subprocess from bentoml.yatai.client import get_yatai_client from tests.bento_service_examples.example_bento_service import ExampleBentoService @@ -16,3 +17,27 @@ def test_yatai_server_containerize_without_push(): tag = 'mytag' built_tag = yc.repository.containerize(bento=f'{svc.name}:{svc.version}', tag=tag) assert built_tag == f'{tag}:{svc.version}' + + +def test_yatai_server_containerize_from_cli(): + svc = ExampleBentoService() + svc.pack('model', [1, 2, 3]) + logger.info('Saving bento service to local yatai server') + svc.save() + bento_tag = f'{svc.name}:{svc.version}' + tag = 'mytagfoo' + + command = [ + 'bentoml', + 'containerize', + bento_tag, + '--build-arg', + 'EXTRA_PIP_INSTALL_ARGS=--extra-index-url=https://pypi.org', + '-t', + tag, + ] + docker_proc = subprocess.Popen( + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + stdout = docker_proc.stdout.read().decode('utf-8') + assert f'{tag}:{svc.version}' in stdout, 'Failed to build container'