11import { buildImage } from "./build" ;
22import {
33 getCloudflareContainerRegistry ,
4- getDevContainerImageName ,
54 isCloudflareRegistryLink ,
65} from "./knobs" ;
76import { dockerLoginManagedRegistry } from "./login" ;
@@ -10,12 +9,11 @@ import {
109 runDockerCmd ,
1110 verifyDockerInstalled ,
1211} from "./utils" ;
13- import type { ContainerNormalizedConfig , RegistryLinkConfig } from "./types" ;
12+ import type { ContainerDevOptions , DockerfileConfig } from "./types" ;
1413
1514export async function pullImage (
1615 dockerPath : string ,
17- options : RegistryLinkConfig ,
18- tag : string
16+ options : Exclude < ContainerDevOptions , DockerfileConfig >
1917) : Promise < { abort : ( ) => void ; ready : Promise < void > } > {
2018 await dockerLoginManagedRegistry ( dockerPath ) ;
2119 const pull = runDockerCmd ( dockerPath , [
@@ -28,7 +26,11 @@ export async function pullImage(
2826 const ready = pull . ready . then ( async ( { aborted } : { aborted : boolean } ) => {
2927 if ( ! aborted ) {
3028 // re-tag image with the expected dev-formatted image tag for consistency
31- await runDockerCmd ( dockerPath , [ "tag" , options . image_uri , tag ] ) ;
29+ await runDockerCmd ( dockerPath , [
30+ "tag" ,
31+ options . image_uri ,
32+ options . image_tag ,
33+ ] ) ;
3234 }
3335 } ) ;
3436
@@ -50,23 +52,23 @@ export async function pullImage(
5052 * such as checking if the Docker CLI is installed, and if the container images
5153 * expose any ports.
5254 */
53- export async function prepareContainerImagesForDev ( options : {
55+ export async function prepareContainerImagesForDev ( args : {
5456 dockerPath : string ;
55- containerOptions : ContainerNormalizedConfig [ ] ;
57+ containerOptions : ContainerDevOptions [ ] ;
5658 onContainerImagePreparationStart : ( args : {
57- containerOptions : ContainerNormalizedConfig ;
59+ containerOptions : ContainerDevOptions ;
5860 abort : ( ) => void ;
5961 } ) => void ;
6062 onContainerImagePreparationEnd : ( args : {
61- containerOptions : ContainerNormalizedConfig [ ] ;
63+ containerOptions : ContainerDevOptions ;
6264 } ) => void ;
6365} ) {
6466 const {
6567 dockerPath,
6668 containerOptions,
6769 onContainerImagePreparationStart,
6870 onContainerImagePreparationEnd,
69- } = options ;
71+ } = args ;
7072 let aborted = false ;
7173 if ( process . platform === "win32" ) {
7274 throw new Error (
@@ -75,9 +77,8 @@ export async function prepareContainerImagesForDev(options: {
7577 }
7678 await verifyDockerInstalled ( dockerPath ) ;
7779 for ( const options of containerOptions ) {
78- const tag = getDevContainerImageName ( options . class_name , containerBuildId ) ;
7980 if ( "dockerfile" in options ) {
80- const build = await buildImage ( dockerPath , options , tag ) ;
81+ const build = await buildImage ( dockerPath , options ) ;
8182 onContainerImagePreparationStart ( {
8283 containerOptions : options ,
8384 abort : ( ) => {
@@ -96,7 +97,7 @@ export async function prepareContainerImagesForDev(options: {
9697 `To use an existing image from another repository, see https://developers.cloudflare.com/containers/image-management/#using-existing-images`
9798 ) ;
9899 }
99- const pull = await pullImage ( dockerPath , options , tag ) ;
100+ const pull = await pullImage ( dockerPath , options ) ;
100101 onContainerImagePreparationStart ( {
101102 containerOptions : options ,
102103 abort : ( ) => {
@@ -110,7 +111,7 @@ export async function prepareContainerImagesForDev(options: {
110111 } ) ;
111112 }
112113 if ( ! aborted ) {
113- await checkExposedPorts ( dockerPath , options , tag ) ;
114+ await checkExposedPorts ( dockerPath , options ) ;
114115 }
115116 }
116117}
0 commit comments