9696 platformsFlagSet = true
9797 return nil
9898 }).Strings ()
99+ containerEngine = "docker"
100+ podmanFlag = crossbuildcmd .Flag ("podman" , "Use podman instead of docker for crossbuild containers." ).Bool ()
99101 // kingpin doesn't currently support using the crossbuild command and the
100102 // crossbuild tarball subcommand at the same time, so we treat the
101103 // tarball subcommand as an optional arg
@@ -112,6 +114,12 @@ func runCrossbuild() {
112114 return
113115 }
114116
117+ if * podmanFlag {
118+ containerEngine = "podman"
119+ } else {
120+ containerEngine = "docker"
121+ }
122+
115123 if crossBuildCgoFlagSet {
116124 config .Go .CGo = * crossBuildCgoFlag
117125 }
@@ -178,7 +186,7 @@ func (pg platformGroup) Build(repoPath string) error {
178186 if * parallelThreadFlag != - 1 {
179187 return pg .buildThread (repoPath , * parallelThreadFlag )
180188 }
181- err := sh .RunCommand ("docker" , "pull" , pg .DockerImage )
189+ err := sh .RunCommand (containerEngine , "pull" , pg .DockerImage )
182190 if err != nil {
183191 return err
184192 }
@@ -208,15 +216,15 @@ func (pg platformGroup) buildThread(repoPath string, p int) error {
208216 return nil
209217 }
210218
211- fmt .Printf ("> running the %s builder docker image\n " , pg .Name )
219+ fmt .Printf ("> running the %s builder %s image\n " , pg .Name , containerEngine )
212220
213221 cwd , err := os .Getwd ()
214222 if err != nil {
215223 return fmt .Errorf ("couldn't get current working directory: %w" , err )
216224 }
217225
218226 ctrName := "promu-crossbuild-" + pg .Name + strconv .FormatInt (time .Now ().Unix (), 10 ) + "-" + strconv .Itoa (p )
219- err = sh .RunCommand ("docker" , "create" , "-t" ,
227+ err = sh .RunCommand (containerEngine , "create" , "-t" ,
220228 "--name" , ctrName ,
221229 pg .DockerImage ,
222230 "-i" , repoPath ,
@@ -225,25 +233,25 @@ func (pg platformGroup) buildThread(repoPath string, p int) error {
225233 return err
226234 }
227235
228- err = sh .RunCommand ("docker" , "cp" ,
236+ err = sh .RunCommand (containerEngine , "cp" ,
229237 cwd + "/." ,
230238 ctrName + ":/app/" )
231239 if err != nil {
232240 return err
233241 }
234242
235- err = sh .RunCommand ("docker" , "start" , "-a" , ctrName )
243+ err = sh .RunCommand (containerEngine , "start" , "-a" , ctrName )
236244 if err != nil {
237245 return err
238246 }
239247
240- err = sh .RunCommand ("docker" , "cp" , "-a" ,
248+ err = sh .RunCommand (containerEngine , "cp" , "-a" ,
241249 ctrName + ":/app/.build/." ,
242250 cwd + "/.build" )
243251 if err != nil {
244252 return err
245253 }
246- return sh .RunCommand ("docker" , "rm" , "-f" , ctrName )
254+ return sh .RunCommand (containerEngine , "rm" , "-f" , ctrName )
247255}
248256
249257func removeDuplicates (strings []string ) []string {
0 commit comments