Skip to content

Commit 2a8ae08

Browse files
authored
fix contentSourceRootPath
1 parent 4e35efe commit 2a8ae08

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/spec-configuration/containerFeaturesConfiguration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,22 +239,22 @@ export function getSourceInfoString(srcInfo: SourceInformation): string {
239239
}
240240

241241
// TODO: Move to node layer.
242-
export function getContainerFeaturesBaseDockerFile(destBasePath = '/opt/build-features/') {
242+
export function getContainerFeaturesBaseDockerFile(contentSourceRootPath: string, destBasePath: string) {
243243
return `
244244
#{featureBuildStages}
245245
246246
#{nonBuildKitFeatureContentFallback}
247247
248248
FROM $_DEV_CONTAINERS_BASE_IMAGE AS dev_containers_feature_content_normalize
249249
USER root
250-
COPY --from=dev_containers_feature_content_source {contentSourceRootPath}/devcontainer-features.builtin.env ${destBasePath}
250+
COPY --from=dev_containers_feature_content_source ${contentSourceRootPath}/devcontainer-features.builtin.env ${destBasePath}
251251
RUN chmod -R 0777 ${destBasePath}
252252
253253
FROM $_DEV_CONTAINERS_BASE_IMAGE AS dev_containers_target_stage
254254
255255
USER root
256256
257-
COPY --from=dev_containers_feature_content_normalize {contentSourceRootPath} ${destBasePath}
257+
COPY --from=dev_containers_feature_content_normalize ${contentSourceRootPath} ${destBasePath}
258258
259259
#{featureLayer}
260260

src/spec-node/containerFeatures.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ async function getFeaturesBuildOptions(params: DockerResolverParameters, devCont
247247
return undefined;
248248
}
249249

250+
output.write(`temporary dstFolder='${dstFolder}'`);
251+
250252
const buildStageScripts = await Promise.all(featuresConfig.featureSets
251253
.map(featureSet => multiStageBuildExploration ? featureSet.features
252254
.filter(f => (includeAllConfiguredFeatures || f.included) && f.value)
@@ -284,10 +286,9 @@ async function getFeaturesBuildOptions(params: DockerResolverParameters, devCont
284286

285287
// When copying via buildkit, the content is accessed via '.' (i.e. in the context root)
286288
// When copying via temp image, the content is in '/opt/build-features'
287-
const contentSourceRootPath = useBuildKitBuildContexts ? '.' : '/opt/build-features/';
288-
const dockerfile = getContainerFeaturesBaseDockerFile()
289+
const contentSourceRootPath = useBuildKitBuildContexts ? '.' : '/tmp/build-features/';
290+
const dockerfile = getContainerFeaturesBaseDockerFile(contentSourceRootPath, '/opt/build-features/')
289291
.replace('#{nonBuildKitFeatureContentFallback}', useBuildKitBuildContexts ? '' : `FROM ${buildContentImageName} as dev_containers_feature_content_source`)
290-
.replace('{contentSourceRootPath}', contentSourceRootPath)
291292
.replace('#{featureBuildStages}', getFeatureBuildStages(featuresConfig, buildStageScripts, contentSourceRootPath))
292293
.replace('#{featureLayer}', getFeatureLayers(featuresConfig, containerUser, remoteUser, useBuildKitBuildContexts, contentSourceRootPath))
293294
.replace('#{containerEnv}', generateContainerEnvs(featuresConfig))
@@ -349,7 +350,7 @@ ARG _DEV_CONTAINERS_BASE_IMAGE=placeholder
349350
if (!useBuildKitBuildContexts) {
350351
const buildContentDockerfile = `
351352
FROM scratch
352-
COPY . /opt/build-features/
353+
COPY . /tmp/build-features/
353354
`;
354355
const buildContentDockerfilePath = cliHost.path.join(dstFolder, 'Dockerfile.buildContent');
355356
await cliHost.writeFile(buildContentDockerfilePath, Buffer.from(buildContentDockerfile));

src/test/container-features/generateFeaturesConfig.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ echo "_CONTAINER_USER_HOME=$(getent passwd testContainerUser | cut -d: -f6)" >>
7676
echo "_REMOTE_USER_HOME=$(getent passwd testRemoteUser | cut -d: -f6)" >> /opt/build-features/devcontainer-features.builtin.env
7777
7878
COPY --chown=root:root --from=dev_containers_feature_content_source /tmp/build-features/first_1 /opt/build-features/first_1
79-
RUN chmod -R 0777 /tmp/build-features/first_1 \\
80-
&& cd /tmp/build-features/first_1 \\
79+
RUN chmod -R 0777 /opt/build-features/first_1 \\
80+
&& cd /opt/build-features/first_1 \\
8181
&& chmod +x ./install.sh \\
8282
&& ./install.sh
8383

0 commit comments

Comments
 (0)