Skip to content

Commit

Permalink
Caching user home location after every feature is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
prulloac committed Apr 2, 2024
1 parent 1da368b commit 6cea28a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/spec-configuration/containerFeaturesConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,17 @@ function escapeQuotesForShell(input: string) {
export function getFeatureLayers(featuresConfig: FeaturesConfig, containerUser: string, remoteUser: string, isBuildah = false, useBuildKitBuildContexts = false, contentSourceRootPath = '/tmp/build-features') {

const useSELinuxLabel = process.platform === 'linux' && isBuildah;

const builtinsEnvFile = `${path.posix.join(FEATURES_CONTAINER_TEMP_DEST_FOLDER, 'devcontainer-features.builtin.env')}`;
let result = `RUN \\
echo "_CONTAINER_USER_HOME=$(${getEntPasswdShellCommand(containerUser)} | cut -d: -f6)" >> ${builtinsEnvFile} && \\
echo "_REMOTE_USER_HOME=$(${getEntPasswdShellCommand(remoteUser)} | cut -d: -f6)" >> ${builtinsEnvFile}

`;
const tempUserHome = `RUN \\
echo "_CONTAINER_USER_HOME=$(${getEntPasswdShellCommand(containerUser)} | cut -d: -f6)" >> ${builtinsEnvFile} && \\
echo "_REMOTE_USER_HOME=$(${getEntPasswdShellCommand(containerUser)} | cut -d: -f6)" >> ${builtinsEnvFile}
`;

// get base image container user home and remote user home
let result = tempUserHome;

// Features version 1
const folders = (featuresConfig.featureSets || []).filter(y => y.internalVersion !== '2').map(x => x.features[0].consecutiveId);
Expand All @@ -323,6 +328,9 @@ RUN chmod -R 0755 ${dest} \\
`;
}

// recalculate container user home and remote user home if feature modifies it
result += tempUserHome;
});
// Features version 2
featuresConfig.featureSets.filter(y => y.internalVersion === '2').forEach(featureSet => {
Expand Down Expand Up @@ -351,6 +359,9 @@ RUN --mount=type=bind,from=dev_containers_feature_content_source,source=${source
`;
}

// recalculate container user home and remote user home if feature modifies it
result += tempUserHome;
});
});
return result;
Expand Down

0 comments on commit 6cea28a

Please sign in to comment.