@@ -486,47 +486,57 @@ async function localBuildImage(options: SelfHostedBuildImageOptions): Promise<Bu
486486 } ;
487487 }
488488
489- const [ credentialsError , credentials ] = await tryCatch (
490- getDockerUsernameAndPassword ( apiClient , deploymentId )
491- ) ;
489+ let credentials ;
490+ if ( cloudRegistryHost . endsWith ( "amazonaws.com" ) ) {
491+ const [ credentialsError , result ] = await tryCatch (
492+ getDockerUsernameAndPassword ( apiClient , deploymentId )
493+ ) ;
492494
493- if ( credentialsError ) {
494- return {
495- ok : false as const ,
496- error : `Failed to get docker credentials: ${ credentialsError . message } ` ,
497- logs : "" ,
498- } ;
495+ if ( credentialsError ) {
496+ return {
497+ ok : false as const ,
498+ error : `Failed to get docker credentials: ${ credentialsError . message } ` ,
499+ logs : "" ,
500+ } ;
501+ }
502+ credentials = result ;
499503 }
500504
501- logger . debug ( `Logging in to docker registry: ${ cloudRegistryHost } ` ) ;
505+ if ( credentials ) {
506+ logger . debug ( `Logging in to docker registry: ${ cloudRegistryHost } ` ) ;
502507
503- const loginProcess = x (
504- "docker" ,
505- [ "login" , "--username" , credentials . username , "--password-stdin" , cloudRegistryHost ] ,
506- {
507- nodeOptions : {
508- cwd : options . cwd ,
509- } ,
510- }
511- ) ;
508+ const loginProcess = x (
509+ "docker" ,
510+ [ "login" , "--username" , credentials . username , "--password-stdin" , cloudRegistryHost ] ,
511+ {
512+ nodeOptions : {
513+ cwd : options . cwd ,
514+ } ,
515+ }
516+ ) ;
512517
513- loginProcess . process ?. stdin ?. write ( credentials . password ) ;
514- loginProcess . process ?. stdin ?. end ( ) ;
518+ loginProcess . process ?. stdin ?. write ( credentials . password ) ;
519+ loginProcess . process ?. stdin ?. end ( ) ;
515520
516- for await ( const line of loginProcess ) {
517- errors . push ( line ) ;
518- logger . debug ( line ) ;
519- }
521+ for await ( const line of loginProcess ) {
522+ errors . push ( line ) ;
523+ logger . debug ( line ) ;
524+ }
520525
521- if ( loginProcess . exitCode !== 0 ) {
522- return {
523- ok : false as const ,
524- error : `Failed to login to registry: ${ cloudRegistryHost } ` ,
525- logs : extractLogs ( errors ) ,
526- } ;
527- }
526+ if ( loginProcess . exitCode !== 0 ) {
527+ return {
528+ ok : false as const ,
529+ error : `Failed to login to registry: ${ cloudRegistryHost } ` ,
530+ logs : extractLogs ( errors ) ,
531+ } ;
532+ }
528533
529- options . onLog ?.( `Successfully logged in to the remote registry` ) ;
534+ options . onLog ?.( `Successfully logged in to the remote registry` ) ;
535+ } else {
536+ logger . debug (
537+ `Skipping automatic registry login for ${ cloudRegistryHost } . Please ensure you are logged in locally.`
538+ ) ;
539+ }
530540 }
531541
532542 const projectCacheRef = getProjectCacheRefFromImageTag ( imageTag ) ;
@@ -550,13 +560,12 @@ async function localBuildImage(options: SelfHostedBuildImageOptions): Promise<Bu
550560 options . noCache ? "--no-cache" : undefined ,
551561 ...( useRegistryCache
552562 ? [
553- "--cache-to" ,
554- `type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=${ projectCacheRef } ${
555- cacheCompression === "zstd" ? ",compression=zstd" : ""
556- } `,
557- "--cache-from" ,
558- `type=registry,ref=${ projectCacheRef } ` ,
559- ]
563+ "--cache-to" ,
564+ `type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=${ projectCacheRef } ${ cacheCompression === "zstd" ? ",compression=zstd" : ""
565+ } `,
566+ "--cache-from" ,
567+ `type=registry,ref=${ projectCacheRef } ` ,
568+ ]
560569 : [ ] ) ,
561570 "--output" ,
562571 outputOptions . join ( "," ) ,
0 commit comments