@@ -28,7 +28,6 @@ import { ImageMetadataEntry, MergedDevContainerConfig } from './imageMetadata';
2828import { getImageIndexEntryForPlatform , getManifest , getRef } from '../spec-configuration/containerCollectionsOCI' ;
2929import { requestEnsureAuthenticated } from '../spec-configuration/httpOCIRegistry' ;
3030import { configFileLabel , findDevContainer , hostFolderLabel } from './singleContainer' ;
31- import { requestResolveHeaders } from '../spec-utils/httpRequest' ;
3231export { getConfigFilePath , getDockerfilePath , isDockerFileConfig } from '../spec-configuration/configuration' ;
3332export { uriToFsPath , parentURI } from '../spec-configuration/configurationCommonUtils' ;
3433
@@ -37,12 +36,6 @@ export type BindMountConsistency = 'consistent' | 'cached' | 'delegated' | undef
3736
3837export type GPUAvailability = 'all' | 'detect' | 'none' ;
3938
40- // Constants for DockerHub registry + image access check
41- const DEVCONTAINER_USER_AGENT = 'devcontainer' ;
42- const DOCKER_MANIFEST_ACCEPT_HEADER = 'application/vnd.docker.distribution.manifest.v2+json' ;
43- const DOCKERFILE_FRONTEND_CHECK_MAX_RETRIES = 5 ;
44- const DOCKERFILE_FRONTEND_CHECK_RETRY_INTERVAL_MS = 2000 ;
45-
4639// Generic retry function
4740export async function retry < T > ( fn : ( ) => Promise < T > , options : { retryIntervalMilliseconds : number ; maxRetries : number ; output : Log } ) : Promise < T > {
4841 const { retryIntervalMilliseconds, maxRetries, output } = options ;
@@ -124,6 +117,7 @@ export interface DockerResolverParameters {
124117 updateRemoteUserUIDDefault : UpdateRemoteUserUIDDefault ;
125118 additionalCacheFroms : string [ ] ;
126119 buildKitVersion : { versionString : string ; versionMatch ?: string } | undefined ;
120+ dockerEngineVersion : { versionString : string ; versionMatch ?: string } | undefined ;
127121 isTTY : boolean ;
128122 experimentalLockfile ?: boolean ;
129123 experimentalFrozenLockfile ?: boolean ;
@@ -609,71 +603,3 @@ export function runAsyncHandler(handler: () => Promise<void>) {
609603 }
610604 } ) ( ) ;
611605}
612-
613- // Helper functions to construct DockerHub URLs
614- function getDockerHubAuthUrl ( imageName : string , version : string ) : string {
615- return `https://auth.docker.io/token?service=registry.docker.io&scope=repository:${ imageName } :pull&tag=${ version } ` ;
616- }
617-
618- function getDockerHubRegistryUrl ( imageName : string , version : string ) : string {
619- return `https://registry-1.docker.io/v2/${ imageName } /manifests/${ version } ` ;
620- }
621-
622- async function checkDockerHubImageAccessible ( params : DockerResolverParameters , imageName : string , version : string ) : Promise < void > {
623- const { output } = params . common ;
624-
625- const authUrl = getDockerHubAuthUrl ( imageName , version ) ;
626- const registryUrl = getDockerHubRegistryUrl ( imageName , version ) ;
627-
628- const tokenRes = await requestResolveHeaders ( {
629- type : 'GET' ,
630- url : authUrl ,
631- headers : { 'user-agent' : DEVCONTAINER_USER_AGENT }
632- } , output ) ;
633- if ( ! tokenRes || tokenRes . statusCode !== 200 ) {
634- throw new Error ( 'Token fetch failed: status ' + ( tokenRes ?. statusCode ?? 'unknown' ) ) ;
635- }
636-
637- let body : any ;
638- try {
639- body = JSON . parse ( tokenRes . resBody . toString ( ) ) ;
640- } catch ( e ) {
641- throw new Error ( 'Token parse failed: ' + ( e instanceof Error ? e . message : String ( e ) ) ) ;
642- }
643- const token : string | undefined = body ?. token || body ?. access_token ;
644- if ( ! token ) {
645- throw new Error ( 'Token missing in auth response' ) ;
646- }
647-
648- const manifestRes = await requestResolveHeaders ( {
649- type : 'GET' ,
650- url : registryUrl ,
651- headers : {
652- 'user-agent' : DEVCONTAINER_USER_AGENT ,
653- 'authorization' : `Bearer ${ token } ` ,
654- 'accept' : DOCKER_MANIFEST_ACCEPT_HEADER
655- }
656- } , output ) ;
657- if ( ! manifestRes || manifestRes . statusCode !== 200 ) {
658- throw new Error ( 'Manifest fetch failed: status ' + ( manifestRes ?. statusCode ?? 'unknown' ) ) ;
659- }
660- }
661-
662- export async function ensureDockerHubImageAccessible ( params : DockerResolverParameters , imageName : string , version : string ) : Promise < boolean > {
663- const { output } = params . common ;
664- try {
665- await retry (
666- async ( ) => { await checkDockerHubImageAccessible ( params , imageName , version ) ; } ,
667- { maxRetries : DOCKERFILE_FRONTEND_CHECK_MAX_RETRIES , retryIntervalMilliseconds : DOCKERFILE_FRONTEND_CHECK_RETRY_INTERVAL_MS , output }
668- ) ;
669- output . write ( 'Dockerfile frontend is accessible in DockerHub registry.' , LogLevel . Info ) ;
670- return true ;
671- } catch ( err ) {
672- output . write (
673- 'Dockerfile frontend check failed after retries: ' +
674- ( err instanceof Error ? err . message : String ( err ) ) ,
675- LogLevel . Warning
676- ) ;
677- return false ;
678- }
679- }
0 commit comments