Skip to content

Commit

Permalink
Check if image name has registry host (microsoft/vscode-remote-releas…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Apr 19, 2024
1 parent d00db63 commit c1c8b08
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Notable changes.

## April 2024

### [0.59.1]
- Check if image name has registry host. (https://github.com/microsoft/vscode-remote-release/issues/9748)

### [0.59.0]
- Propagate --cache-from to buildx build. (https://github.com/devcontainers/cli/pull/638)
- Disable cache on feature build when `--build-no-cache` is passed. (https://github.com/devcontainers/cli/pull/790)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@devcontainers/cli",
"description": "Dev Containers CLI",
"version": "0.59.0",
"version": "0.59.1",
"bin": {
"devcontainer": "devcontainer.js"
},
Expand Down
11 changes: 10 additions & 1 deletion src/spec-node/containerFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ export async function updateRemoteUserUID(params: DockerResolverParameters, merg
'-f', destDockerfile,
'-t', fixedImageName,
...(platform ? ['--platform', platform] : []),
'--build-arg', `BASE_IMAGE=${params.isPodman ? 'localhost/' : ''}${imageName}`, // Podman: https://github.com/microsoft/vscode-remote-release/issues/9748
'--build-arg', `BASE_IMAGE=${params.isPodman && !hasRegistryHostname(imageName) ? 'localhost/' : ''}${imageName}`, // Podman: https://github.com/microsoft/vscode-remote-release/issues/9748
'--build-arg', `REMOTE_USER=${remoteUser}`,
'--build-arg', `NEW_UID=${await cliHost.getuid!()}`,
'--build-arg', `NEW_GID=${await cliHost.getgid!()}`,
Expand All @@ -445,3 +445,12 @@ export async function updateRemoteUserUID(params: DockerResolverParameters, merg
}
return fixedImageName;
}

function hasRegistryHostname(imageName: string) {
if (imageName.startsWith('localhost/')) {
return true;
}
const dot = imageName.indexOf('.');
const slash = imageName.indexOf('/');
return dot !== -1 && slash !== -1 && dot < slash;
}

0 comments on commit c1c8b08

Please sign in to comment.