summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gcp/release-docker.yaml2
-rw-r--r--scripts/build_sandbox.js24
2 files changed, 19 insertions, 7 deletions
diff --git a/.gcp/release-docker.yaml b/.gcp/release-docker.yaml
index 67a21c56..59220b8d 100644
--- a/.gcp/release-docker.yaml
+++ b/.gcp/release-docker.yaml
@@ -48,7 +48,7 @@ steps:
- |
export GEMINI_SANDBOX_IMAGE_TAG=$$(cat /workspace/image_tag.txt)
echo "Using Docker image tag for build: $$GEMINI_SANDBOX_IMAGE_TAG"
- npm run build:sandbox
+ npm run build:sandbox -- --output-file /workspace/final_image_uri.txt
env:
- 'GEMINI_SANDBOX=$_CONTAINER_TOOL'
diff --git a/scripts/build_sandbox.js b/scripts/build_sandbox.js
index 51d0556e..7eece434 100644
--- a/scripts/build_sandbox.js
+++ b/scripts/build_sandbox.js
@@ -40,6 +40,11 @@ const argv = yargs(hideBin(process.argv))
alias: 'image',
type: 'string',
description: 'use <image> name for custom image',
+ })
+ .option('output-file', {
+ type: 'string',
+ description:
+ 'Path to write the final image URI. Used for CI/CD pipeline integration.',
}).argv;
let sandboxCommand;
@@ -134,14 +139,21 @@ function buildImage(imageName, dockerfile) {
{ stdio: buildStdout, shell: '/bin/bash' },
);
console.log(`built ${finalImageName}`);
- if (existsSync('/workspace/final_image_uri.txt')) {
- // The publish step only supports one image. If we build multiple, only the last one
- // will be published. Throw an error to make this failure explicit.
- throw new Error(
- 'CI artifact file /workspace/final_image_uri.txt already exists. Refusing to overwrite.',
+
+ // If an output file path was provided via command-line, write the final image URI to it.
+ if (argv.outputFile) {
+ console.log(
+ `Writing final image URI for CI artifact to: ${argv.outputFile}`,
);
+ // The publish step only supports one image. If we build multiple, only the last one
+ // will be published. Throw an error to make this failure explicit if the file already exists.
+ if (existsSync(argv.outputFile)) {
+ throw new Error(
+ `CI artifact file ${argv.outputFile} already exists. Refusing to overwrite.`,
+ );
+ }
+ writeFileSync(argv.outputFile, finalImageName);
}
- writeFileSync('/workspace/final_image_uri.txt', finalImageName);
}
if (baseImage && baseDockerfile) {