Ejemplo n.º 1
0
 def test_build_no_login(self, login_mock, build_mock):
     build(
         context=".",
         destination="image_name:image_tag",
         nocache=True,
         registries=None,
     )
     assert login_mock.call_count == 0
     assert build_mock.call_count == 1
Ejemplo n.º 2
0
 def test_build_raise_timeout(self, build_mock):
     build_mock.side_effect = ReadTimeoutError(None, "foo", "error")
     with self.assertRaises(PolyaxonBuildException):
         build(
             context=".",
             destination="image_name:image_tag",
             nocache=True,
             max_retries=1,
             sleep_interval=0,
         )
Ejemplo n.º 3
0
 def test_build_login(self, login_mock, build_mock):
     build(
         context=".",
         destination="image_name:image_tag",
         nocache=True,
         registries=[
             V1UriType("user", "pwd", "host"),
             V1UriType("user", "pwd", "host"),
         ],
     )
     assert login_mock.call_count == 2
     assert build_mock.call_count == 1
Ejemplo n.º 4
0
def build(context, destination, nocache, max_retries, sleep_interval, reraise):
    """Build a dockerfile, this command required Docker to be installed."""
    from polyaxon.builds.builder import build

    try:
        validate_image(destination)
    except ValidationError as e:
        handle_cli_error(e, message="Image destination is invalid.")

    try:
        build(
            context=context,
            destination=destination,
            nocache=nocache,
            max_retries=max_retries,
            sleep_interval=sleep_interval,
        )
    except PolyaxonBuildException as e:
        handle_cli_error(e, message="Docker build failed")
        if reraise:
            raise e
        sys.exit(1)