@@ -15,7 +15,8 @@ logging.basicConfig(level=logging.INFO,
15
15
format = "%(asctime)s %(levelname)s - %(message)s" )
16
16
17
17
18
- def build_container_image (labels , buildDir , fromimage , cacheTTL , repo , tag ):
18
+ def build_container_image (labels , buildDir , fromimage , cacheTTL ,
19
+ repo , tag , secret , mount_ca , security_opt ):
19
20
'''
20
21
Build the image using podman remote and push to the registry
21
22
@param labels list labels to add to image
@@ -30,6 +31,13 @@ def build_container_image(labels, buildDir, fromimage, cacheTTL, repo, tag):
30
31
cmd .extend ([f"--label={ label } " ])
31
32
if fromimage :
32
33
cmd .extend ([f"--from={ fromimage } " ])
34
+ if secret :
35
+ for s in secret :
36
+ cmd .append (f"--secret={ s } " )
37
+ if mount_ca :
38
+ cmd .extend (["-v" , "/etc/pki/ca-trust:/etc/pki/ca-trust:ro" ])
39
+ if security_opt :
40
+ cmd .extend (["--security-opt" , security_opt ])
33
41
# Long running command. Send output to stdout for logging
34
42
runcmd (cmd )
35
43
@@ -173,7 +181,9 @@ def main():
173
181
logging .info ("Building container via podman" )
174
182
builddir = os .path .join (gitdir , args .git_sub_dir )
175
183
build_container_image (args .labels , builddir , args .fromimage ,
176
- args .cache_ttl , args .repo , args .tag )
184
+ args .cache_ttl , args .repo , args .tag ,
185
+ args .secret , args .mount_host_ca_certs ,
186
+ args .security_opt )
177
187
178
188
# Push to the registry if needed, else save the image to a file
179
189
if args .push_to_registry :
@@ -200,6 +210,8 @@ Examples:
200
210
--git-ref main \
201
211
--git-url https://github.com/coreos/coreos-assembler.git \
202
212
--repo quay.io/coreos/coreos-assembler-staging \
213
+ --mount-host-ca-certs \
214
+ --secret id=yumrepos,src=/path/to/rhel-9.6.repo \
203
215
--push-to-registry """ )
204
216
205
217
parser .add_argument (
@@ -212,9 +224,6 @@ Examples:
212
224
'--cache-ttl' , default = "0.1s" , required = False ,
213
225
help = """Pass along --cache-ttl=<value> to `podman build`.
214
226
Defaults to 0.1s, which is effectively `--no-cache`""" )
215
- parser .add_argument (
216
- '--label' , dest = "labels" , default = [], action = 'append' ,
217
- required = False , help = 'Add image label(s)' )
218
227
parser .add_argument (
219
228
'--force' , required = False , action = 'store_true' ,
220
229
help = 'Force image overwrite' )
@@ -230,9 +239,21 @@ Examples:
230
239
parser .add_argument (
231
240
'--git-sub-dir' , default = '' , required = False ,
232
241
help = 'Git sub directory to use for container build' )
242
+ parser .add_argument (
243
+ '--label' , dest = "labels" , default = [], action = 'append' ,
244
+ required = False , help = 'Add image label(s)' )
245
+ parser .add_argument (
246
+ '--mount-host-ca-certs' , required = False , action = 'store_true' ,
247
+ help = 'Mount the CA certificate from the remote host' )
233
248
parser .add_argument (
234
249
'--repo' , default = 'localhost' , required = False ,
235
250
help = 'Registry repository' )
251
+ parser .add_argument (
252
+ '--secret' , required = False , action = 'append' , default = [],
253
+ help = 'Provide a local secret for remote access. Uses the same syntax as `podman build --secret`' )
254
+ parser .add_argument (
255
+ '--security-opt' , required = False ,
256
+ help = 'Set SELinux options. Uses the same syntax as `podman build --security-opt`' )
236
257
parser .add_argument (
237
258
'--tag' , required = False ,
238
259
help = 'Force image tag. The default is arch-commit' )
0 commit comments