MCPcopy Index your code
hub / github.com/devcontainers/cli / updateRemoteUserUID

Function updateRemoteUserUID

src/spec-node/containerFeatures.ts:445–483  ·  view source on GitHub ↗
(params: DockerResolverParameters, mergedConfig: MergedDevContainerConfig, imageName: string, imageDetails: () => Promise<ImageDetails>, runArgsUser: string | undefined)

Source from the content-addressed store, hash-verified

443}
444
445export async function updateRemoteUserUID(params: DockerResolverParameters, mergedConfig: MergedDevContainerConfig, imageName: string, imageDetails: () => Promise<ImageDetails>, runArgsUser: string | undefined) {
446 const { common } = params;
447 const { cliHost } = common;
448
449 const updateDetails = await getRemoteUserUIDUpdateDetails(params, mergedConfig, imageName, imageDetails, runArgsUser);
450 if (!updateDetails) {
451 return imageName;
452 }
453 const { imageName: fixedImageName, remoteUser, imageUser, platform } = updateDetails;
454
455 const dockerfileName = 'updateUID.Dockerfile';
456 const srcDockerfile = path.join(common.extensionPath, 'scripts', dockerfileName);
457 const version = common.package.version;
458 const destDockerfile = cliHost.path.join(await getCacheFolder(cliHost), `${dockerfileName}-${version}`);
459 const tmpDockerfile = `${destDockerfile}-${Date.now()}`;
460 await cliHost.mkdirp(cliHost.path.dirname(tmpDockerfile));
461 await cliHost.writeFile(tmpDockerfile, await readLocalFile(srcDockerfile));
462 await cliHost.rename(tmpDockerfile, destDockerfile);
463 const emptyFolder = getEmptyContextFolder(common);
464 await cliHost.mkdirp(emptyFolder);
465 const args = [
466 'build',
467 '-f', destDockerfile,
468 '-t', fixedImageName,
469 ...(platform ? ['--platform', platform] : []),
470 '--build-arg', `BASE_IMAGE=${params.cliVariant === CLIVariant.Podman && !hasRegistryHostname(imageName) ? 'localhost/' : ''}${imageName}`, // Podman: https://github.com/microsoft/vscode-remote-release/issues/9748
471 '--build-arg', `REMOTE_USER=${remoteUser}`,
472 '--build-arg', `NEW_UID=${await cliHost.getuid!()}`,
473 '--build-arg', `NEW_GID=${await cliHost.getgid!()}`,
474 '--build-arg', `IMAGE_USER=${imageUser}`,
475 emptyFolder,
476 ];
477 if (params.isTTY) {
478 await dockerPtyCLI(params, ...args);
479 } else {
480 await dockerCLI(params, ...args);
481 }
482 return fixedImageName;
483}
484
485function hasRegistryHostname(imageName: string) {
486 if (imageName.startsWith('localhost/')) {

Callers 2

startContainerFunction · 0.90

Calls 9

getCacheFolderFunction · 0.90
getEmptyContextFolderFunction · 0.90
dockerPtyCLIFunction · 0.90
dockerCLIFunction · 0.90
hasRegistryHostnameFunction · 0.85
renameMethod · 0.80
mkdirpMethod · 0.65
writeFileMethod · 0.65

Tested by

no test coverage detected