From 422f05d25be11bff974af74f2e62c833f6321144 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sat, 11 Feb 2023 08:22:37 +0000 Subject: [PATCH] Use squash only if podman is used --- kernel.go | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/kernel.go b/kernel.go index 8a7d086..8528978 100644 --- a/kernel.go +++ b/kernel.go @@ -96,8 +96,14 @@ func (cmd *KernelDockerRegenCmd) Run(kernelCmd *KernelCmd, g *Globals) (err erro return } - cmd := exec.Command("docker", "build", "--squash", "-t", - d.ContainerName, imagePath) + args := []string{"build"} + _, err = exec.Command("which", "podman").CombinedOutput() + if err != nil { + args = append(args, "--squash") + } + args = append(args, "-t", d.ContainerName, imagePath) + + cmd := exec.Command("docker", args...) var rawOutput []byte rawOutput, err = cmd.CombinedOutput() if err != nil { @@ -346,7 +352,14 @@ func generateBaseDockerImage(registry string, commands []config.DockerCommand, return } - cmd = exec.Command("docker", "build", "--squash", "-t", sk.DockerName(), imagePath) + args := []string{"build"} + _, err = exec.Command("which", "podman").CombinedOutput() + if err != nil { + args = append(args, "--squash") + } + args = append(args, "-t", sk.DockerName(), imagePath) + + cmd = exec.Command("docker", args...) rawOutput, err = cmd.CombinedOutput() if err != nil { log.Printf("Base image for %s:%s generating error, see log", @@ -413,7 +426,14 @@ func dockerImageAppend(sk config.KernelMask, pkgname string) (err error) { return } - cmd := exec.Command("docker", "build", "--squash", "-t", sk.DockerName(), imagePath) + args := []string{"build"} + _, err = exec.Command("which", "podman").CombinedOutput() + if err != nil { + args = append(args, "--squash") + } + args = append(args, "-t", sk.DockerName(), imagePath) + + cmd := exec.Command("docker", args...) rawOutput, err := cmd.CombinedOutput() if err != nil { // Fallback to previous state