Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/spec-configuration/containerFeaturesConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,21 @@ export function getFeatureLayers(featuresConfig: FeaturesConfig, containerUser:

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

`;

// placeholder empty string to concatenate the feature layers
let result = '';

// Features version 1
const folders = (featuresConfig.featureSets || []).filter(y => y.internalVersion !== '2').map(x => x.features[0].consecutiveId);
folders.forEach(folder => {
// calculate container user home and remote user home before feature installation
result += tempUserHome;

const source = path.posix.join(contentSourceRootPath, folder!);
const dest = path.posix.join(FEATURES_CONTAINER_TEMP_DEST_FOLDER, folder!);
if (!useBuildKitBuildContexts) {
Expand All @@ -327,6 +333,9 @@ RUN chmod -R 0755 ${dest} \\
// Features version 2
featuresConfig.featureSets.filter(y => y.internalVersion === '2').forEach(featureSet => {
featureSet.features.forEach(feature => {
// recalculate container user home and remote user home if feature modifies it
result += tempUserHome;

result += generateContainerEnvs(feature.containerEnv);
const source = path.posix.join(contentSourceRootPath, feature.consecutiveId!);
const dest = path.posix.join(FEATURES_CONTAINER_TEMP_DEST_FOLDER, feature.consecutiveId!);
Expand Down
4 changes: 4 additions & 0 deletions src/test/container-features/generateFeaturesConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ RUN chmod -R 0755 /tmp/dev-container-features/color_0 \\
&& chmod +x ./devcontainer-features-install.sh \\
&& ./devcontainer-features-install.sh

RUN \\
echo "_CONTAINER_USER_HOME=$(${getEntPasswdShellCommand('testContainerUser')} | cut -d: -f6)" >> /tmp/dev-container-features/devcontainer-features.builtin.env && \\
echo "_REMOTE_USER_HOME=$(${getEntPasswdShellCommand('testRemoteUser')} | cut -d: -f6)" >> /tmp/dev-container-features/devcontainer-features.builtin.env


COPY --chown=root:root --from=dev_containers_feature_content_source /tmp/build-features/hello_1 /tmp/dev-container-features/hello_1
RUN chmod -R 0755 /tmp/dev-container-features/hello_1 \\
Expand Down