@@ -8,6 +8,8 @@ TILT_IMAGES_UNAPPLY = os.path.abspath("./bin/tilt-images-unapply")
8
8
# Allow the use of the azimuth-dev context
9
9
allow_k8s_contexts ("azimuth" )
10
10
11
+ # Increase the timeout for applying to Kubernetes
12
+ update_settings (k8s_upsert_timeout_secs = 600 )
11
13
12
14
def deep_merge (dict1 , dict2 ):
13
15
"""
@@ -34,6 +36,13 @@ if not os.path.exists(SETTINGS_FILE):
34
36
# Load the settings
35
37
settings = deep_merge (
36
38
{
39
+ # The engine that will be used to build container images for your changes
40
+ # Supported options are docker, podman
41
+ "build_engine" : "docker" ,
42
+ # The engine that will be used to mirror container images when required
43
+ # Supported options are skopeo (recommended), docker, podman
44
+ # Defaults to the build engine
45
+ # "mirror_engine": "skopeo",
37
46
# The components that will be managed by Tilt, if locally available
38
47
# By default, we search for local checkouts as siblings of this checkout
39
48
"components" : {
@@ -101,27 +110,23 @@ def build_image(name, context, build_args = None):
101
110
"""
102
111
Defines an image build and returns the image name.
103
112
"""
113
+ build_engine = settings ["build_engine" ]
114
+ if build_engine not in ["docker" , "podman" ]:
115
+ fail ("unknown build engine - %s" % build_engine )
104
116
image = image_name (name )
105
- # The Azimuth CaaS operator relies on the .git folder to be in the Docker build context
106
- # This is because it uses pbr for versioning
107
- # Unfortunately, Tilt's docker_build function _always_ ignores the .git directory :-(
117
+ # Some of the Azimuth components rely on the .git folder to be in the build context (pbr)
118
+ # Unfortunately, Tilt's {docker,podman}_build functions _always_ ignores the .git directory
108
119
# So we use a custom build command
109
- build_command = [
110
- "docker" ,
111
- "build" ,
112
- "-t" ,
113
- "$EXPECTED_REF" ,
114
- "--platform" ,
115
- "linux/amd64" ,
116
- context ,
117
- ]
118
- if build_args :
119
- for arg_name , arg_value in build_args .items ():
120
- build_command .extend ([
121
- "--build-arg" ,
122
- "'%s=%s'" % (arg_name , arg_value ),
123
- ])
124
- custom_build (image , " " .join (build_command ), [context ])
120
+ build_args = " " .join ([
121
+ item
122
+ for arg_name , arg_value in (build_args or {}).items ()
123
+ for item in ["--build-arg" , "'%s=%s'" % (arg_name , arg_value )]
124
+ ])
125
+ build_command = (
126
+ "%s build -t $EXPECTED_REF --platform linux/amd64 %s %s && " % (build_engine , build_args , context ) +
127
+ "%s push $EXPECTED_REF" % build_engine
128
+ )
129
+ custom_build (image , build_command , [context ], skips_local_docker = True )
125
130
return image
126
131
127
132
@@ -130,14 +135,18 @@ def mirror_image(name, source_image):
130
135
Defines a mirrored image and returns the image name.
131
136
"""
132
137
image = image_name (name )
133
- custom_build (
134
- image ,
135
- (
136
- "docker pull --platform linux/amd64 {source_image} && " +
137
- "docker tag {source_image} $EXPECTED_REF"
138
- ).format (source_image = source_image ),
139
- []
140
- )
138
+ mirror_engine = settings .get ("mirror_engine" ) or settings ["build_engine" ]
139
+ if mirror_engine in ["docker" , "podman" ]:
140
+ mirror_command = (
141
+ "%s pull --platform linux/amd64 %s && " % (mirror_engine , source_image ) +
142
+ "%s tag %s $EXPECTED_REF && " % (mirror_engine , source_image ) +
143
+ "%s push $EXPECTED_REF" % mirror_engine
144
+ )
145
+ elif mirror_engine == "skopeo" :
146
+ mirror_command = "skopeo copy --all docker://%s docker://$EXPECTED_REF" % source_image
147
+ else :
148
+ fail ("unrecognised mirror engine - %s" % mirror_engine )
149
+ custom_build (image , mirror_command , [], skips_local_docker = True )
141
150
return image
142
151
143
152
0 commit comments