@@ -208,6 +208,18 @@ pub struct ImagesReplacement {
208208
209209pub static PREVENT_METADATA_LOCK : & str = ".deployer-prevent-metadata.lock.json" ;
210210
211+ pub fn choose_executor ( opts : & ContaineredOpts , sudo : bool ) -> String {
212+ if opts. executor . as_ref ( ) . unwrap ( ) == "podman" {
213+ "sudo podman" . to_string ( )
214+ } else {
215+ format ! ( "{}docker" , if sudo { "" } else { "sudo " } )
216+ }
217+ }
218+
219+ pub fn is_docker ( opts : & ContaineredOpts ) -> bool {
220+ opts. executor . is_none ( ) || opts. executor . as_ref ( ) . unwrap ( ) == "docker"
221+ }
222+
211223pub fn check_and_pull_once (
212224 env : & RunEnvironment ,
213225 opts : & mut ContaineredOpts ,
@@ -217,20 +229,16 @@ pub fn check_and_pull_once(
217229 let mut repls = crate :: rw:: read :: < ImagesReplacement > ( env. run_dir , PREVENT_METADATA_LOCK ) ;
218230 if repls. base_from . ne ( opts. base_image . as_deref ( ) . unwrap_or ( BASE_IMAGE ) ) {
219231 if !repls. base_to . is_empty ( )
220- && run_simple (
221- env,
222- format ! ( "{}docker rmi {}" , if sudo { "" } else { "sudo " } , repls. base_to) ,
223- )
224- . is_err ( )
232+ && run_simple ( env, format ! ( "{} rmi {}" , choose_executor( opts, sudo) , repls. base_to) ) . is_err ( )
225233 {
226234 println ! ( "{}" , i18n:: CTRD_CANT_REMOVE_OLD_IMG . red( ) ) ;
227235 exit ( 1 ) ;
228236 }
229237 if run_simple (
230238 env,
231239 format ! (
232- "{}docker pull {}" ,
233- if sudo { "" } else { "sudo " } ,
240+ "{} pull {}" ,
241+ choose_executor ( opts , sudo) ,
234242 opts. base_image. as_deref( ) . unwrap_or( BASE_IMAGE )
235243 ) ,
236244 )
@@ -242,8 +250,8 @@ pub fn check_and_pull_once(
242250 if run_simple (
243251 env,
244252 format ! (
245- "{}docker tag {} {}_executor:latest" ,
246- if sudo { "" } else { "sudo " } ,
253+ "{} tag {} {}_executor:latest" ,
254+ choose_executor ( opts , sudo) ,
247255 opts. base_image. as_deref( ) . unwrap_or( BASE_IMAGE ) ,
248256 exclusive_exec_tag
249257 ) ,
@@ -261,20 +269,16 @@ pub fn check_and_pull_once(
261269 . ne ( opts. build_deployer_base_image . as_deref ( ) . unwrap_or ( BASE_IMAGE ) )
262270 {
263271 if !repls. depl_to . is_empty ( )
264- && run_simple (
265- env,
266- format ! ( "{}docker rmi {}" , if sudo { "" } else { "sudo " } , repls. depl_to) ,
267- )
268- . is_err ( )
272+ && run_simple ( env, format ! ( "{} rmi {}" , choose_executor( opts, sudo) , repls. depl_to) ) . is_err ( )
269273 {
270274 println ! ( "{}" , i18n:: CTRD_CANT_REMOVE_OLD_IMG . red( ) ) ;
271275 exit ( 1 ) ;
272276 }
273277 if run_simple (
274278 env,
275279 format ! (
276- "{}docker pull {}" ,
277- if sudo { "" } else { "sudo " } ,
280+ "{} pull {}" ,
281+ choose_executor ( opts , sudo) ,
278282 opts. build_deployer_base_image. as_deref( ) . unwrap_or( BASE_IMAGE )
279283 ) ,
280284 )
@@ -286,8 +290,8 @@ pub fn check_and_pull_once(
286290 if run_simple (
287291 env,
288292 format ! (
289- "{}docker tag {} {}_builder:latest" ,
290- if sudo { "" } else { "sudo " } ,
293+ "{} tag {} {}_builder:latest" ,
294+ choose_executor ( opts , sudo) ,
291295 opts. build_deployer_base_image. as_deref( ) . unwrap_or( BASE_IMAGE ) ,
292296 exclusive_exec_tag
293297 ) ,
@@ -341,13 +345,13 @@ pub fn execute_pipeline_containered(
341345 ) ;
342346
343347 let build_cmd = format ! (
344- "{}docker build {}-t {}/{} -f Dockerfile.{}{} ." ,
345- if sudo { "" } else { "sudo " } ,
348+ "{} build {}-t {}/{} -f Dockerfile.{}{} ." ,
349+ choose_executor ( & opts , sudo) ,
346350 if env. new_build { "--no-cache " } else { "" } ,
347351 config. project_name,
348352 pipeline. title,
349353 exclusive_exec_tag,
350- if opts. use_containerd_local_storage_cache. is_some_and( |v| v) {
354+ if opts. use_containerd_local_storage_cache. is_some_and( |v| v) && is_docker ( & opts ) {
351355 format!(
352356 " --cache-to type=local,dest=.docker-cache/{},compression=zstd --cache-from type=local,src=.docker-cache/{}" ,
353357 exclusive_exec_tag, exclusive_exec_tag
@@ -364,11 +368,18 @@ pub fn execute_pipeline_containered(
364368
365369 let volume_path = env. artifacts_dir . join ( & pipeline. title ) ;
366370
371+ if !is_docker ( & opts) {
372+ std:: fs:: create_dir_all (
373+ env
374+ . artifacts_dir
375+ . join ( pipeline. exclusive_exec_tag . as_deref ( ) . unwrap_or ( "default" ) ) ,
376+ ) ?;
377+ }
367378 if run_simple (
368379 env,
369380 format ! (
370- "{}docker run -v {:?}:/app/artifacts {}/{}" ,
371- if sudo { "" } else { "sudo " } ,
381+ "{} run -v {:?}:/app/artifacts {}/{}" ,
382+ choose_executor ( & opts , sudo) ,
372383 volume_path,
373384 config. project_name,
374385 pipeline. title
0 commit comments