Skip to content

Commit 6cea28a

Browse files
committed
Caching user home location after every feature is installed
1 parent 1da368b commit 6cea28a

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/spec-configuration/containerFeaturesConfiguration.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,17 @@ function escapeQuotesForShell(input: string) {
292292
export function getFeatureLayers(featuresConfig: FeaturesConfig, containerUser: string, remoteUser: string, isBuildah = false, useBuildKitBuildContexts = false, contentSourceRootPath = '/tmp/build-features') {
293293

294294
const useSELinuxLabel = process.platform === 'linux' && isBuildah;
295+
295296
const builtinsEnvFile = `${path.posix.join(FEATURES_CONTAINER_TEMP_DEST_FOLDER, 'devcontainer-features.builtin.env')}`;
296-
let result = `RUN \\
297-
echo "_CONTAINER_USER_HOME=$(${getEntPasswdShellCommand(containerUser)} | cut -d: -f6)" >> ${builtinsEnvFile} && \\
298-
echo "_REMOTE_USER_HOME=$(${getEntPasswdShellCommand(remoteUser)} | cut -d: -f6)" >> ${builtinsEnvFile}
299297

300-
`;
298+
const tempUserHome = `RUN \\
299+
echo "_CONTAINER_USER_HOME=$(${getEntPasswdShellCommand(containerUser)} | cut -d: -f6)" >> ${builtinsEnvFile} && \\
300+
echo "_REMOTE_USER_HOME=$(${getEntPasswdShellCommand(containerUser)} | cut -d: -f6)" >> ${builtinsEnvFile}
301+
302+
`;
303+
304+
// get base image container user home and remote user home
305+
let result = tempUserHome;
301306

302307
// Features version 1
303308
const folders = (featuresConfig.featureSets || []).filter(y => y.internalVersion !== '2').map(x => x.features[0].consecutiveId);
@@ -323,6 +328,9 @@ RUN chmod -R 0755 ${dest} \\
323328
324329
`;
325330
}
331+
332+
// recalculate container user home and remote user home if feature modifies it
333+
result += tempUserHome;
326334
});
327335
// Features version 2
328336
featuresConfig.featureSets.filter(y => y.internalVersion === '2').forEach(featureSet => {
@@ -351,6 +359,9 @@ RUN --mount=type=bind,from=dev_containers_feature_content_source,source=${source
351359
352360
`;
353361
}
362+
363+
// recalculate container user home and remote user home if feature modifies it
364+
result += tempUserHome;
354365
});
355366
});
356367
return result;

0 commit comments

Comments
 (0)