You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Builds (or pulls - TODO) the container images for local development. This
76
-
* will be called before starting the local development server, and by a rebuild
77
-
* hotkey during development.
78
-
*
79
-
* Because this runs when local dev starts, we also do some validation here,
80
-
* such as checking if the Docker CLI is installed, and if the container images
81
-
* expose any ports.
82
-
*/
83
-
exportasyncfunctionprepareContainerImagesForDev(
84
-
dockerPath: string,
85
-
containerOptions: ContainerDevOptions[]
86
-
){
87
-
if(process.platform==="win32"){
88
-
thrownewError(
89
-
"Local development with containers is currently not supported on Windows. You should use WSL instead. You can also set `enable_containers` to false if you do not need to develop the container as part of your application."
Copy file name to clipboardExpand all lines: packages/containers-shared/src/images.ts
+62Lines changed: 62 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,14 @@
1
1
import{execFile}from"child_process";
2
+
import{buildImage}from"./build";
3
+
import{isCloudflareRegistryLink}from"./knobs";
4
+
import{dockerLoginManagedRegistry}from"./login";
5
+
import{ContainerDevOptions}from"./types";
6
+
import{
7
+
checkExposedPorts,
8
+
isDockerfile,
9
+
runDockerCmd,
10
+
verifyDockerInstalled,
11
+
}from"./utils";
2
12
3
13
// Returns a list of docker image ids matching the provided repository:[tag]
4
14
exportasyncfunctiongetDockerImageDigest(
@@ -22,3 +32,55 @@ export async function getDockerImageDigest(
22
32
);
23
33
});
24
34
}
35
+
36
+
exportasyncfunctionpullImage(
37
+
dockerPath: string,
38
+
options: ContainerDevOptions
39
+
){
40
+
awaitdockerLoginManagedRegistry(dockerPath);
41
+
awaitrunDockerCmd(dockerPath,[
42
+
"pull",
43
+
options.image,
44
+
// All containers running on our platform need to be built for amd64 architecture, but by default docker pull seems to look for an image matching the host system, so we need to specify this here
45
+
"--platform",
46
+
"linux/amd64",
47
+
]);
48
+
// re-tag image with the expected dev-formatted image tag for consistency
* Builds or pulls the container images for local development. This
55
+
* will be called before starting the local development server, and by a rebuild
56
+
* hotkey during development.
57
+
*
58
+
* Because this runs when local dev starts, we also do some validation here,
59
+
* such as checking if the Docker CLI is installed, and if the container images
60
+
* expose any ports.
61
+
*/
62
+
exportasyncfunctionprepareContainerImagesForDev(
63
+
dockerPath: string,
64
+
containerOptions: ContainerDevOptions[]
65
+
){
66
+
if(process.platform==="win32"){
67
+
thrownewError(
68
+
"Local development with containers is currently not supported on Windows. You should use WSL instead. You can also set `enable_containers` to false if you do not need to develop the container part of your application."
69
+
);
70
+
}
71
+
awaitverifyDockerInstalled(dockerPath);
72
+
for(constoptionsofcontainerOptions){
73
+
if(isDockerfile(options.image)){
74
+
awaitbuildImage(dockerPath,options);
75
+
}else{
76
+
if(!isCloudflareRegistryLink(options.image)){
77
+
thrownewError(
78
+
`Image "${options.image}" is a registry link but does not point to the Cloudflare container registry.\n`+
79
+
`To use an existing image from another repository, see https://developers.cloudflare.com/containers/image-management/#using-existing-images`
0 commit comments