Skip to content

Commit 0b5720c

Browse files
committed
Enable --cache-to in devcontainer up
1 parent be1f203 commit 0b5720c

File tree

7 files changed

+20
-1
lines changed

7 files changed

+20
-1
lines changed

src/spec-common/injectHeadless.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export interface ResolverParameters {
6262
buildxPush: boolean;
6363
buildxOutput: string | undefined;
6464
buildxCacheTo: string | undefined;
65+
buildxCacheFrom: string | undefined;
6566
skipFeatureAutoMapping: boolean;
6667
skipPostAttach: boolean;
6768
containerSessionDataFolder?: string;

src/spec-node/containerFeatures.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ export async function extendImage(params: DockerResolverParameters, config: Subs
8989
params.additionalCacheFroms.forEach(cacheFrom => args.push('--cache-from', cacheFrom));
9090
}
9191

92+
if (params.buildxCacheFrom) {
93+
args.push('--cache-from', params.buildxCacheFrom);
94+
}
95+
9296
for (const buildContext in featureBuildInfo.buildKitContexts) {
9397
args.push('--build-context', `${buildContext}=${featureBuildInfo.buildKitContexts[buildContext]}`);
9498
}

src/spec-node/devContainers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface ProvisionOptions {
5454
buildxPush: boolean;
5555
buildxOutput: string | undefined;
5656
buildxCacheTo: string | undefined;
57+
buildxCacheFrom: string | undefined;
5758
additionalFeatures?: Record<string, string | boolean | Record<string, string | boolean>>;
5859
skipFeatureAutoMapping: boolean;
5960
skipPostAttach: boolean;
@@ -144,6 +145,7 @@ export async function createDockerParams(options: ProvisionOptions, disposables:
144145
buildxPush: options.buildxPush,
145146
buildxOutput: options.buildxOutput,
146147
buildxCacheTo: options.buildxCacheTo,
148+
buildxCacheFrom: options.buildxCacheFrom,
147149
skipFeatureAutoMapping: options.skipFeatureAutoMapping,
148150
skipPostAttach: options.skipPostAttach,
149151
containerSessionDataFolder: options.containerSessionDataFolder,

src/spec-node/devContainersSpecCLI.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function provisionOptions(y: Argv) {
123123
'mount': { type: 'string', description: 'Additional mount point(s). Format: type=<bind|volume>,source=<source>,target=<target>[,external=<true|false>]' },
124124
'remote-env': { type: 'string', description: 'Remote environment variables of the format name=value. These will be added when executing the user commands.' },
125125
'cache-from': { type: 'string', description: 'Additional image to use as potential layer cache during image building' },
126+
'cache-to': { type: 'string', description: 'Additional image to use as potential layer cache during image building' },
126127
'buildkit': { choices: ['auto' as 'auto', 'never' as 'never'], default: 'auto' as 'auto', description: 'Control whether BuildKit should be used' },
127128
'additional-features': { type: 'string', description: 'Additional features to apply to the dev container (JSON as per "features" section in devcontainer.json)' },
128129
'skip-feature-auto-mapping': { type: 'boolean', default: false, hidden: true, description: 'Temporary option for testing.' },
@@ -193,6 +194,7 @@ async function provision({
193194
mount,
194195
'remote-env': addRemoteEnv,
195196
'cache-from': addCacheFrom,
197+
'cache-to': addCacheTo,
196198
'buildkit': buildkit,
197199
'additional-features': additionalFeaturesJson,
198200
'skip-feature-auto-mapping': skipFeatureAutoMapping,
@@ -262,7 +264,8 @@ async function provision({
262264
buildxPlatform: undefined,
263265
buildxPush: false,
264266
buildxOutput: undefined,
265-
buildxCacheTo: undefined,
267+
buildxCacheTo: addCacheTo,
268+
buildxCacheFrom: addCacheFrom,
266269
additionalFeatures,
267270
skipFeatureAutoMapping,
268271
skipPostAttach,
@@ -418,6 +421,7 @@ async function doSetUp({
418421
buildxPush: false,
419422
buildxOutput: undefined,
420423
buildxCacheTo: undefined,
424+
buildxCacheFrom: undefined,
421425
skipFeatureAutoMapping: false,
422426
skipPostAttach: false,
423427
skipPersistingCustomizationsFromFeatures: false,
@@ -843,6 +847,7 @@ async function doRunUserCommands({
843847
buildxPush: false,
844848
buildxOutput: undefined,
845849
buildxCacheTo: undefined,
850+
buildxCacheFrom: undefined,
846851
skipFeatureAutoMapping,
847852
skipPostAttach,
848853
skipPersistingCustomizationsFromFeatures: false,
@@ -1290,6 +1295,7 @@ export async function doExec({
12901295
buildxPlatform: undefined,
12911296
buildxPush: false,
12921297
buildxCacheTo: undefined,
1298+
buildxCacheFrom: undefined,
12931299
skipFeatureAutoMapping,
12941300
buildxOutput: undefined,
12951301
skipPostAttach: false,

src/spec-node/featuresCLI/testCommandImpl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ async function generateDockerParams(workspaceFolder: string, args: FeaturesTestC
654654
buildxPush: false,
655655
buildxOutput: undefined,
656656
buildxCacheTo: undefined,
657+
buildxCacheFrom: undefined,
657658
skipFeatureAutoMapping: false,
658659
skipPostAttach: false,
659660
skipPersistingCustomizationsFromFeatures: false,

src/spec-node/singleContainer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ async function buildAndExtendImage(buildParams: DockerResolverParameters, config
202202
if (buildParams.buildxCacheTo) {
203203
args.push('--cache-to', buildParams.buildxCacheTo);
204204
}
205+
if (buildParams.buildxCacheFrom) {
206+
args.push('--cache-from', buildParams.buildxCacheFrom);
207+
}
208+
205209
args.push('--build-arg', 'BUILDKIT_INLINE_CACHE=1');
206210
} else {
207211
args.push('build');

src/spec-node/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export interface DockerResolverParameters {
118118
buildxPush: boolean;
119119
buildxOutput: string | undefined;
120120
buildxCacheTo: string | undefined;
121+
buildxCacheFrom: string | undefined;
121122
platformInfo: PlatformInfo;
122123
}
123124

0 commit comments

Comments
 (0)