@@ -34,6 +34,13 @@ if not os.path.exists(SETTINGS_FILE):
34
34
# Load the settings
35
35
settings = deep_merge (
36
36
{
37
+ # The engine that will be used to build container images for your changes
38
+ # Supported options are docker, podman
39
+ "build_engine" : "docker" ,
40
+ # The engine that will be used to mirror container images when required
41
+ # Supported options are skopeo (recommended), docker, podman
42
+ # Defaults to the build engine
43
+ # "mirror_engine": "skopeo",
37
44
# The components that will be managed by Tilt, if locally available
38
45
# By default, we search for local checkouts as siblings of this checkout
39
46
"components" : {
@@ -101,27 +108,23 @@ def build_image(name, context, build_args = None):
101
108
"""
102
109
Defines an image build and returns the image name.
103
110
"""
111
+ build_engine = settings ["build_engine" ]
112
+ if build_engine not in ["docker" , "podman" ]:
113
+ fail ("unknown build engine - %s" % build_engine )
104
114
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 :-(
115
+ # Some of the Azimuth components rely on the .git folder to be in the build context (pbr)
116
+ # Unfortunately, Tilt's {docker,podman}_build functions _always_ ignores the .git directory
108
117
# 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 ])
118
+ build_args = " " .join ([
119
+ item
120
+ for arg_name , arg_value in (build_args or {}).items ()
121
+ for item in ["--build-arg" , "'%s=%s'" % (arg_name , arg_value )]
122
+ ])
123
+ build_command = (
124
+ "%s build -t $EXPECTED_REF --platform linux/amd64 %s %s && " % (build_engine , build_args , context ) +
125
+ "%s push $EXPECTED_REF" % build_engine
126
+ )
127
+ custom_build (image , build_command , [context ], skips_local_docker = True )
125
128
return image
126
129
127
130
@@ -130,14 +133,18 @@ def mirror_image(name, source_image):
130
133
Defines a mirrored image and returns the image name.
131
134
"""
132
135
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
- )
136
+ mirror_engine = settings .get ("mirror_engine" ) or settings ["build_engine" ]
137
+ if mirror_engine in ["docker" , "podman" ]:
138
+ mirror_command = (
139
+ "%s pull --platform linux/amd64 %s && " % (mirror_engine , source_image ) +
140
+ "%s tag %s $EXPECTED_REF && " % (mirror_engine , source_image ) +
141
+ "%s push $EXPECTED_REF" % mirror_engine
142
+ )
143
+ elif mirror_engine == "skopeo" :
144
+ mirror_command = "skopeo copy --all docker://%s docker://$EXPECTED_REF" % source_image
145
+ else :
146
+ fail ("unrecognised mirror engine - %s" % mirror_engine )
147
+ custom_build (image , mirror_command , [], skips_local_docker = True )
141
148
return image
142
149
143
150
0 commit comments