feat(CI): Add a github action to build the sandbox image and push to GHCR (#8670)

Co-authored-by: matt korwel <matt.korwel@gmail.com>
This commit is contained in:
Richie Foreman
2025-09-20 10:19:03 -04:00
committed by GitHub
parent 44691a4ce6
commit aba23feddd
3 changed files with 125 additions and 13 deletions

View File

@@ -41,11 +41,13 @@ const argv = yargs(hideBin(process.argv))
.option('f', {
alias: 'dockerfile',
type: 'string',
default: 'Dockerfile',
description: 'use <dockerfile> for custom image',
})
.option('i', {
alias: 'image',
type: 'string',
default: cliPkgJson.config.sandboxImageUri,
description: 'use <image> name for custom image',
})
.option('output-file', {
@@ -74,12 +76,10 @@ if (sandboxCommand === 'sandbox-exec') {
console.log(`using ${sandboxCommand} for sandboxing`);
const baseImage = cliPkgJson.config.sandboxImageUri;
const customImage = argv.i;
const baseDockerfile = 'Dockerfile';
const customDockerfile = argv.f;
const image = argv.i;
const dockerFile = argv.f;
if (!baseImage?.length) {
if (!image.length) {
console.warn(
'No default image tag specified in gemini-cli/packages/cli/package.json',
);
@@ -160,7 +160,7 @@ function buildImage(imageName, dockerfile) {
execSync(
`${sandboxCommand} build ${buildCommandArgs} ${
process.env.BUILD_SANDBOX_FLAGS || ''
} --build-arg CLI_VERSION_ARG=${npmPackageVersion} -f "${dockerfile}" -t "${imageName}" .`,
} --build-arg CLI_VERSION_ARG=${npmPackageVersion} -f "${dockerfile}" -t "${finalImageName}" .`,
{ stdio: buildStdout, shell: shellToUse },
);
console.log(`built ${finalImageName}`);
@@ -187,12 +187,6 @@ function buildImage(imageName, dockerfile) {
}
}
if (baseImage && baseDockerfile) {
buildImage(baseImage, baseDockerfile);
}
if (customDockerfile && customImage) {
buildImage(customImage, customDockerfile);
}
buildImage(image, dockerFile);
execSync(`${sandboxCommand} image prune -f`, { stdio: 'ignore' });