feat(docker): add Docker context detection, rootless support, and context-aware buildx registry handling
This commit is contained in:
@@ -151,7 +151,7 @@ export class Dockerfile {
|
||||
}
|
||||
|
||||
/** Starts a temporary registry:2 container on port 5234. */
|
||||
public static async startLocalRegistry(): Promise<void> {
|
||||
public static async startLocalRegistry(isRootless?: boolean): Promise<void> {
|
||||
await smartshellInstance.execSilent(
|
||||
`docker rm -f ${LOCAL_REGISTRY_CONTAINER} 2>/dev/null || true`
|
||||
);
|
||||
@@ -164,6 +164,9 @@ export class Dockerfile {
|
||||
// registry:2 starts near-instantly; brief wait for readiness
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
logger.log('info', `Started local registry at ${LOCAL_REGISTRY_HOST} (buildx dependency bridge)`);
|
||||
if (isRootless) {
|
||||
logger.log('warn', `[rootless] Registry on port ${LOCAL_REGISTRY_PORT} — if buildx cannot reach localhost:${LOCAL_REGISTRY_PORT}, try 127.0.0.1:${LOCAL_REGISTRY_PORT}`);
|
||||
}
|
||||
}
|
||||
|
||||
/** Stops and removes the temporary local registry container. */
|
||||
@@ -191,14 +194,14 @@ export class Dockerfile {
|
||||
*/
|
||||
public static async buildDockerfiles(
|
||||
sortedArrayArg: Dockerfile[],
|
||||
options?: { platform?: string; timeout?: number; noCache?: boolean; verbose?: boolean },
|
||||
options?: { platform?: string; timeout?: number; noCache?: boolean; verbose?: boolean; isRootless?: boolean },
|
||||
): Promise<Dockerfile[]> {
|
||||
const total = sortedArrayArg.length;
|
||||
const overallStart = Date.now();
|
||||
const useRegistry = Dockerfile.needsLocalRegistry(sortedArrayArg, options);
|
||||
|
||||
if (useRegistry) {
|
||||
await Dockerfile.startLocalRegistry();
|
||||
await Dockerfile.startLocalRegistry(options?.isRootless);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user