summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-02-15 11:35:34 +0100
committerMatthew Heon <mheon@redhat.com>2021-02-18 10:43:41 -0500
commit2f3ae7ce5bbe03db13acfa529b5a396e65de1655 (patch)
tree9bac9b7812e5c43cd13cdef3401dd0f25ff4384d
parent8d11461a7a659830619cfcdfa2999f8a65beb79a (diff)
downloadpodman-2f3ae7ce5bbe03db13acfa529b5a396e65de1655.tar.gz
podman-2f3ae7ce5bbe03db13acfa529b5a396e65de1655.tar.bz2
podman-2f3ae7ce5bbe03db13acfa529b5a396e65de1655.zip
podman build: pass runtime to buildah
Make sure that Podman's default OCI runtime is passed to Buildah in `podman build`. In theory, Podman and Buildah should use the same defaults but the projects move at different speeds and it turns out we caused a regression in v3.0. Fixes: #9365 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
-rw-r--r--libpod/runtime_img.go5
-rw-r--r--test/system/070-build.bats25
2 files changed, 30 insertions, 0 deletions
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go
index 2c5442bd2..e6caf2626 100644
--- a/libpod/runtime_img.go
+++ b/libpod/runtime_img.go
@@ -166,6 +166,11 @@ func (r *Runtime) newImageBuildCompleteEvent(idOrName string) {
// Build adds the runtime to the imagebuildah call
func (r *Runtime) Build(ctx context.Context, options imagebuildah.BuildOptions, dockerfiles ...string) (string, reference.Canonical, error) {
+ if options.Runtime == "" {
+ // Make sure that build containers use the same runtime as Podman (see #9365).
+ conf := util.DefaultContainerConfig()
+ options.Runtime = conf.Engine.OCIRuntime
+ }
id, ref, err := imagebuildah.BuildDockerfiles(ctx, r.store, options, dockerfiles...)
// Write event for build completion
r.newImageBuildCompleteEvent(id)
diff --git a/test/system/070-build.bats b/test/system/070-build.bats
index bf9fa789c..000998f3a 100644
--- a/test/system/070-build.bats
+++ b/test/system/070-build.bats
@@ -46,6 +46,31 @@ EOF
is "$output" ".*invalidflag" "failed when passing undefined flags to the runtime"
}
+@test "podman build - set runtime" {
+ skip_if_remote "--runtime flag not supported for remote"
+ # Test on the CLI and via containers.conf
+
+ tmpdir=$PODMAN_TMPDIR/build-test
+ run mkdir -p $tmpdir
+ containerfile=$tmpdir/Containerfile
+ cat >$containerfile <<EOF
+FROM $IMAGE
+RUN echo $rand_content
+EOF
+
+ run_podman 125 --runtime=idonotexist build -t build_test $tmpdir
+ is "$output" ".*\"idonotexist\" not found.*" "failed when passing invalid OCI runtime via CLI"
+
+ containersconf=$tmpdir/containers.conf
+ cat >$containersconf <<EOF
+[engine]
+runtime="idonotexist"
+EOF
+
+ CONTAINERS_CONF="$containersconf" run_podman 125 build -t build_test $tmpdir
+ is "$output" ".*\"idonotexist\" not found.*" "failed when passing invalid OCI runtime via containers.conf"
+}
+
# Regression from v1.5.0. This test passes fine in v1.5.0, fails in 1.6
@test "podman build - cache (#3920)" {
# Make an empty test directory, with a subdirectory used for tar