From cbd0f250c88ce5c0da5d8934437bf4b2d2ada42b Mon Sep 17 00:00:00 2001 From: Dana Dahlstrom Date: Mon, 6 Jan 2025 18:00:00 -0800 Subject: [PATCH] Don't read files from current working directory Issue: 365150653 Reviewed-on: https://github.com/youtube/cobalt/pull/4656 --- cobalt/devinfra/kokoro/bin/dind_builder_runner.sh | 1 - cobalt/devinfra/kokoro/bin/dind_py/dind_common.py | 6 ++---- .../devinfra/kokoro/bin/dind_py/main_build_image_and_run.py | 3 ++- cobalt/devinfra/kokoro/bin/dind_runner.sh | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cobalt/devinfra/kokoro/bin/dind_builder_runner.sh b/cobalt/devinfra/kokoro/bin/dind_builder_runner.sh index efe6f5998b93..b9135d48b334 100755 --- a/cobalt/devinfra/kokoro/bin/dind_builder_runner.sh +++ b/cobalt/devinfra/kokoro/bin/dind_builder_runner.sh @@ -25,7 +25,6 @@ set -ueEx # Using repository root as work directory. export WORKSPACE_COBALT="${KOKORO_ARTIFACTS_DIR}/git/src" -cd "${WORKSPACE_COBALT}" # Clean up workspace on exit or error. trap "bash ${WORKSPACE_COBALT}/cobalt/devinfra/kokoro/bin/cleanup.sh" EXIT INT TERM diff --git a/cobalt/devinfra/kokoro/bin/dind_py/dind_common.py b/cobalt/devinfra/kokoro/bin/dind_py/dind_common.py index ff32f292f96c..d6bb8f367b37 100644 --- a/cobalt/devinfra/kokoro/bin/dind_py/dind_common.py +++ b/cobalt/devinfra/kokoro/bin/dind_py/dind_common.py @@ -66,7 +66,7 @@ def push_image(target_image): utils.exec_cmd(command) -def get_local_image_name(service, compose_file='docker-compose.yaml'): +def get_local_image_name(service, compose_file): """ Parses the docker-compose file to determine the image-name from the service-name. When the compose-file is used to build the image, it will get @@ -86,9 +86,7 @@ def tag_image(src_img, dest_img): utils.exec_cmd(tag_command) -def run_docker_build(platform, - target_image, - compose_file='docker-compose.yaml'): +def run_docker_build(platform, target_image, compose_file): """ Runs the docker build for the provided platform, and tags the newly built image with the registry/image/tag arguments. If the build fails, instead it diff --git a/cobalt/devinfra/kokoro/bin/dind_py/main_build_image_and_run.py b/cobalt/devinfra/kokoro/bin/dind_py/main_build_image_and_run.py index 196d161b1655..46fb9bccf981 100644 --- a/cobalt/devinfra/kokoro/bin/dind_py/main_build_image_and_run.py +++ b/cobalt/devinfra/kokoro/bin/dind_py/main_build_image_and_run.py @@ -93,7 +93,8 @@ def main(): utils.logging_info_spacer('Building Docker Image') build_start_time = time.time() try: - dind.run_docker_build(args.platform, target_image) + dind.run_docker_build(args.platform, target_image, + args.src_root + '/docker-compose.yaml') dind.tag_image(target_image, floating_image) dind.push_image(floating_image) docker_build_duration = time.time() - build_start_time diff --git a/cobalt/devinfra/kokoro/bin/dind_runner.sh b/cobalt/devinfra/kokoro/bin/dind_runner.sh index 012fc58fa94a..ed0534e236e6 100755 --- a/cobalt/devinfra/kokoro/bin/dind_runner.sh +++ b/cobalt/devinfra/kokoro/bin/dind_runner.sh @@ -25,7 +25,6 @@ set -ueEx # Using repository root as work directory. export WORKSPACE_COBALT="${KOKORO_ARTIFACTS_DIR}/git/src" -cd "${WORKSPACE_COBALT}" # Clean up workspace on exit or error. trap "bash ${WORKSPACE_COBALT}/cobalt/devinfra/kokoro/bin/cleanup.sh" EXIT INT TERM