From 8afbc9c14adfffbf2f5f1796164514dba6a7e6bf Mon Sep 17 00:00:00 2001 From: Carl Eqladios Date: Fri, 20 Sep 2024 18:56:50 +0300 Subject: [PATCH] fix: default to legacy builder instead of BuildKit with podman - Podman doesn't support all buildkit features. - Podman main branch is now always defaulting to "DOCKER_BUILDKIT=0", See https://github.com/containers/podman/blob/f7be7a365ad3e90db5f96f269a555f6f380f9275/cmd/podman/compose.go#L164 - fix: make cli ignore `--buildkit` parameter and default to `never` when Podman is used. --- src/spec-node/devContainers.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/spec-node/devContainers.ts b/src/spec-node/devContainers.ts index 493d0dc22..88877c9ba 100644 --- a/src/spec-node/devContainers.ts +++ b/src/spec-node/devContainers.ts @@ -13,7 +13,7 @@ import { createNullLifecycleHook, finishBackgroundTasks, ResolverParameters, Use import { GoARCH, GoOS, getCLIHost, loadNativeModule } from '../spec-common/commonUtils'; import { resolve } from './configContainer'; import { URI } from 'vscode-uri'; -import { LogLevel, LogDimensions, toErrorText, createCombinedLog, createTerminalLog, Log, makeLog, LogFormat, createJSONLog, createPlainLog, LogHandler, replaceAllLog } from '../spec-utils/log'; +import { LogLevel, LogDimensions, toErrorText, toWarningText, createCombinedLog, createTerminalLog, Log, makeLog, LogFormat, createJSONLog, createPlainLog, LogHandler, replaceAllLog } from '../spec-utils/log'; import { dockerComposeCLIConfig } from './dockerCompose'; import { Mount } from '../spec-configuration/containerFeaturesConfiguration'; import { getPackageConfig, PackageConfiguration } from '../spec-utils/product'; @@ -197,14 +197,18 @@ export async function createDockerParams(options: ProvisionOptions, disposables: } })(); - const buildKitVersion = options.useBuildKit === 'never' ? undefined : (await dockerBuildKitVersion({ - cliHost, - dockerCLI: dockerPath, - dockerComposeCLI, - env: cliHost.env, - output, - platformInfo - })); + const buildKitVersion = async () => { + if (options.useBuildKit === 'never') { + return undefined; + } else { + if (await isPodman({ exec: cliHost.exec, cmd: dockerPath, env: cliHost.env, output })) { + output.write(toWarningText('Podman does not support BuildKit, defaulting to legacy builder.')); + return undefined; + } + return await dockerBuildKitVersion({ cliHost, dockerCLI: dockerPath, dockerComposeCLI, env: cliHost.env, output, platformInfo }); + } + }; + return { common, parsedAuthority, @@ -224,7 +228,7 @@ export async function createDockerParams(options: ProvisionOptions, disposables: userRepositoryConfigurationPaths: [], updateRemoteUserUIDDefault, additionalCacheFroms: options.additionalCacheFroms, - buildKitVersion, + buildKitVersion: await buildKitVersion(), isTTY: process.stdout.isTTY || options.logFormat === 'json', experimentalLockfile, experimentalFrozenLockfile,