Пример #1
0
def main(args: dict) -> None:
    # set current path as working dir
    os.chdir(HERE)

    version = args.get(build_utils.FLAG_VERSION)
    docker_image_prefix = args.get(build_docker.FLAG_DOCKER_IMAGE_PREFIX)

    if not docker_image_prefix:
        docker_image_prefix = DOCKER_IMAGE_PREFIX  # type: ignore

    if args.get(build_utils.FLAG_MAKE):
        build_docker.build_docker_image(COMPONENT_NAME,
                                        version,
                                        exit_on_error=True)

    if args.get(build_utils.FLAG_CHECK):
        pass
        #  build_docker.lint_dockerfile(exit_on_error=True)
        # TODO: the python base image currently has vulnerabilities
        # build_docker.check_image(
        #     image=build_docker.get_image_name(name=COMPONENT_NAME, tag=version),
        #     exit_on_error=True,
        # )

    if args.get(build_utils.FLAG_RELEASE):
        build_docker.release_docker_image(
            COMPONENT_NAME,
            version,
            docker_image_prefix,
            exit_on_error=True,
        )
Пример #2
0
def main(args: dict) -> None:
    # set current path as working dir
    os.chdir(HERE)

    version = args.get(build_utils.FLAG_VERSION)
    docker_image_prefix = DOCKER_IMAGE_PREFIX
    if args.get(build_docker.FLAG_DOCKER_IMAGE_PREFIX):
        docker_image_prefix = args.get(
            build_docker.FLAG_DOCKER_IMAGE_PREFIX)  # type: ignore

    if args.get(build_utils.FLAG_MAKE):
        build_docker.build_docker_image(COMPONENT_NAME,
                                        version,
                                        exit_on_error=True)

    if args.get(build_utils.FLAG_CHECK):
        build_docker.lint_dockerfile(exit_on_error=False)

        exit_on_error = False if build_utils.FLAG_FORCE else True
        completed_process = build_docker.check_image(
            image=build_docker.get_image_name(name=COMPONENT_NAME,
                                              tag=version),
            exit_on_error=exit_on_error,
        )
        if completed_process and completed_process.returncode != 0:
            build_utils.log(
                f"The security check failed, but is ignored because {build_utils.FLAG_FORCE} flag is set."
            )

    if args.get(build_utils.FLAG_RELEASE):
        build_docker.release_docker_image(COMPONENT_NAME,
                                          version,
                                          docker_image_prefix,
                                          exit_on_error=True)
Пример #3
0
    workspace_port = "8080"
    client = docker.from_env()
    container = client.containers.run(
        f"{docker_image_name}:{VERSION}",
        name=workspace_name,
        environment={
            "WORKSPACE_NAME": workspace_name,
            "WORKSPACE_ACCESS_PORT": workspace_port,
        },
        detach=True,
    )

    container.reload()
    container_ip = container.attrs["NetworkSettings"]["Networks"]["bridge"][
        "IPAddress"]

    completed_process = build_utils.run(
        f"docker exec --env WORKSPACE_IP={container_ip} {workspace_name} pytest '/resources/tests'",
        exit_on_error=False,
    )

    container.remove(force=True)
    if completed_process.returncode > 0:
        build_utils.exit_process(1)

if args.get(build_utils.FLAG_RELEASE):
    build_docker.release_docker_image(docker_image_name,
                                      VERSION,
                                      docker_image_prefix,
                                      exit_on_error=True)
Пример #4
0
        "IPAddress"]

    completed_process = build_utils.run(
        f"docker exec --env WORKSPACE_IP={container_ip} {workspace_name} pytest '/resources/tests'",
        exit_on_error=False,
    )

    container.remove(force=True)
    if completed_process.returncode > 0:
        build_utils.exit_process(1)

if args[build_utils.FLAG_RELEASE]:
    # Bump all versions in some filess
    previous_version = build_utils.get_latest_version()
    if previous_version:
        build_utils.replace_in_files(
            previous_version,
            VERSION,
            file_paths=[
                "./README.md", "./deployment/google-cloud-run/Dockerfile"
            ],
            regex=False,
            exit_on_error=True,
        )

    build_docker.release_docker_image(
        docker_image_name,
        VERSION,
        docker_image_prefix,
    )
Пример #5
0
from universal_build import build_utils
from universal_build.helpers import build_docker

COMPONENT_NAME = "simple-demo-job"

args = build_utils.parse_arguments()
if args[build_utils.FLAG_MAKE]:
    completed_process = build_docker.build_docker_image(
        COMPONENT_NAME, args[build_utils.FLAG_VERSION])
    if completed_process.returncode > 0:
        build_utils.exit_process(completed_process.returncode)

if args[build_utils.FLAG_RELEASE]:
    completed_process = build_docker.release_docker_image(
        COMPONENT_NAME, args[build_utils.FLAG_VERSION],
        args[build_docker.FLAG_DOCKER_IMAGE_PREFIX])
Пример #6
0
        )

        lab_service_port = build_utils.run(
            f"docker inspect {kind_cluster_name}-control-plane | jq -r '.[0].NetworkSettings.Ports[\"30002/tcp\"][0].HostPort'",
            exit_on_error=True).stdout.strip()

        completed_process = build_utils.run(f"SERVICES_RUNTIME=k8s \
            KUBE_CONFIG_PATH=kube-config \
            LAB_DATA_ROOT=/workspace/data \
            SERVICE_VERSION={args[build_utils.FLAG_VERSION]} \
            LAB_SERVICE_PORT={lab_service_port} \
            LAB_KUBERNETES_NAMESPACE=ml-test \
            IS_KIND_CLUSTER=True \
            mvn verify")
        if completed_process.returncode > 0:
            build_utils.log(
                f"Tests failed in Kubernetes mode for component {COMPONENT_NAME}"
            )
            build_utils.exit_process(1)
    else:
        build_utils.log(
            "Skipping Kubernetes tests because kind is not installed.")

# Only allow releasing from sub componenents when force flag is set as an extra precaution step
if args[build_utils.FLAG_RELEASE] and args[build_utils.FLAG_FORCE]:
    build_docker.release_docker_image(
        COMPONENT_NAME,
        args[build_utils.FLAG_VERSION],
        args[build_docker.FLAG_DOCKER_IMAGE_PREFIX],
    )