feat(cli/buildx): add pull control for builds and isolate buildx builders per project

This commit is contained in:
2026-03-19 10:18:10 +00:00
parent 3e4558abc5
commit 8cf8e43e59
7 changed files with 41 additions and 18 deletions

View File

@@ -25,6 +25,7 @@ export class TsDockerManager {
public projectInfo: any;
public dockerContext: DockerContext;
public session!: TsDockerSession;
public currentBuilderName?: string;
private dockerfiles: Dockerfile[] = [];
private activeRemoteBuilders: IRemoteBuilder[] = [];
private sshTunnelManager?: SshTunnelManager;
@@ -266,6 +267,7 @@ export class TsDockerManager {
platform: options?.platform,
timeout: options?.timeout,
noCache: options?.noCache,
pull: options?.pull,
verbose: options?.verbose,
});
logger.log('ok', `${progress} Built ${df.cleanTag} in ${formatDuration(elapsed)}`);
@@ -311,6 +313,7 @@ export class TsDockerManager {
platform: options?.platform,
timeout: options?.timeout,
noCache: options?.noCache,
pull: options?.pull,
verbose: options?.verbose,
});
logger.log('ok', `${progress} Built ${dockerfileArg.cleanTag} in ${formatDuration(elapsed)}`);
@@ -349,6 +352,7 @@ export class TsDockerManager {
platform: options?.platform,
timeout: options?.timeout,
noCache: options?.noCache,
pull: options?.pull,
verbose: options?.verbose,
isRootless: this.dockerContext.contextInfo?.isRootless,
parallel: options?.parallel,
@@ -401,6 +405,7 @@ export class TsDockerManager {
await this.ensureBuildxLocal(builderName);
}
this.currentBuilderName = builderName;
logger.log('ok', `Docker buildx ready (builder: ${builderName}, platforms: ${platforms})`);
}
@@ -426,7 +431,7 @@ export class TsDockerManager {
// Create the local node
const localPlatformFlag = localPlatforms.length > 0 ? ` --platform ${localPlatforms.join(',')}` : '';
await smartshellInstance.exec(
`docker buildx create --name ${builderName} --driver docker-container --driver-opt network=host${localPlatformFlag} --use`
`docker buildx create --name ${builderName} --driver docker-container --driver-opt network=host${localPlatformFlag}`
);
// Append remote nodes
@@ -441,7 +446,7 @@ export class TsDockerManager {
}
// Bootstrap all nodes
await smartshellInstance.exec('docker buildx inspect --bootstrap');
await smartshellInstance.exec(`docker buildx inspect --builder ${builderName} --bootstrap`);
// Store active remote builders for SSH tunnel setup during build
this.activeRemoteBuilders = remoteBuilders;
@@ -456,20 +461,18 @@ export class TsDockerManager {
if (inspectResult.exitCode !== 0) {
logger.log('info', 'Creating new buildx builder with host network...');
await smartshellInstance.exec(
`docker buildx create --name ${builderName} --driver docker-container --driver-opt network=host --use`
`docker buildx create --name ${builderName} --driver docker-container --driver-opt network=host`
);
await smartshellInstance.exec('docker buildx inspect --bootstrap');
await smartshellInstance.exec(`docker buildx inspect --builder ${builderName} --bootstrap`);
} else {
const inspectOutput = inspectResult.stdout || '';
if (!inspectOutput.includes('network=host')) {
logger.log('info', 'Recreating buildx builder with host network (migration)...');
await smartshellInstance.exec(`docker buildx rm ${builderName} 2>/dev/null`);
await smartshellInstance.exec(
`docker buildx create --name ${builderName} --driver docker-container --driver-opt network=host --use`
`docker buildx create --name ${builderName} --driver docker-container --driver-opt network=host`
);
await smartshellInstance.exec('docker buildx inspect --bootstrap');
} else {
await smartshellInstance.exec(`docker buildx use ${builderName}`);
await smartshellInstance.exec(`docker buildx inspect --builder ${builderName} --bootstrap`);
}
}
this.activeRemoteBuilders = [];