mirror of
https://github.com/containers/podman.git
synced 2025-06-21 01:19:15 +08:00
@ -116,6 +116,7 @@ func buildFlags(cmd *cobra.Command) {
|
|||||||
// --layers flag
|
// --layers flag
|
||||||
flag = layerFlags.Lookup("layers")
|
flag = layerFlags.Lookup("layers")
|
||||||
useLayersVal := useLayers()
|
useLayersVal := useLayers()
|
||||||
|
buildOpts.Layers = useLayersVal == "true"
|
||||||
if err := flag.Value.Set(useLayersVal); err != nil {
|
if err := flag.Value.Set(useLayersVal); err != nil {
|
||||||
logrus.Errorf("unable to set --layers to %v: %v", useLayersVal, err)
|
logrus.Errorf("unable to set --layers to %v: %v", useLayersVal, err)
|
||||||
}
|
}
|
||||||
@ -275,11 +276,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check to see if the BUILDAH_LAYERS environment variable is set and
|
flags.Layers = buildOpts.Layers
|
||||||
// override command-line.
|
|
||||||
if _, ok := os.LookupEnv("BUILDAH_LAYERS"); ok {
|
|
||||||
flags.Layers = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// `buildah bud --layers=false` acts like `docker build --squash` does.
|
// `buildah bud --layers=false` acts like `docker build --squash` does.
|
||||||
// That is all of the new layers created during the build process are
|
// That is all of the new layers created during the build process are
|
||||||
|
@ -71,6 +71,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
ForceRm bool `schema:"forcerm"`
|
ForceRm bool `schema:"forcerm"`
|
||||||
HTTPProxy bool `schema:"httpproxy"`
|
HTTPProxy bool `schema:"httpproxy"`
|
||||||
Labels string `schema:"labels"`
|
Labels string `schema:"labels"`
|
||||||
|
Layers bool `schema:"layers"`
|
||||||
MemSwap int64 `schema:"memswap"`
|
MemSwap int64 `schema:"memswap"`
|
||||||
Memory int64 `schema:"memory"`
|
Memory int64 `schema:"memory"`
|
||||||
NetworkMode string `schema:"networkmode"`
|
NetworkMode string `schema:"networkmode"`
|
||||||
@ -165,6 +166,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
Registry: query.Registry,
|
Registry: query.Registry,
|
||||||
IgnoreUnrecognizedInstructions: true,
|
IgnoreUnrecognizedInstructions: true,
|
||||||
Quiet: query.Quiet,
|
Quiet: query.Quiet,
|
||||||
|
Layers: query.Layers,
|
||||||
Isolation: buildah.IsolationChroot,
|
Isolation: buildah.IsolationChroot,
|
||||||
Compression: archive.Gzip,
|
Compression: archive.Gzip,
|
||||||
Args: buildArgs,
|
Args: buildArgs,
|
||||||
|
@ -41,6 +41,9 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
|
|||||||
if options.NoCache {
|
if options.NoCache {
|
||||||
params.Set("nocache", "1")
|
params.Set("nocache", "1")
|
||||||
}
|
}
|
||||||
|
if options.Layers {
|
||||||
|
params.Set("layers", "1")
|
||||||
|
}
|
||||||
// TODO cachefrom
|
// TODO cachefrom
|
||||||
if options.PullPolicy == buildah.PullAlways {
|
if options.PullPolicy == buildah.PullAlways {
|
||||||
params.Set("pull", "1")
|
params.Set("pull", "1")
|
||||||
|
@ -381,6 +381,48 @@ a${random3}z"
|
|||||||
run_podman rmi -f build_test
|
run_podman rmi -f build_test
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "podman build --layers test" {
|
||||||
|
rand_content=$(random_string 50)
|
||||||
|
tmpdir=$PODMAN_TMPDIR/build-test
|
||||||
|
run mkdir -p $tmpdir
|
||||||
|
containerfile=$tmpdir/Containerfile
|
||||||
|
cat >$containerfile <<EOF
|
||||||
|
FROM $IMAGE
|
||||||
|
RUN echo $rand_content
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Build twice to make sure second time uses cache
|
||||||
|
run_podman build -t build_test $tmpdir
|
||||||
|
if [[ "$output" =~ "Using cache" ]]; then
|
||||||
|
is "$output" "[no instance of 'Using cache']" "no cache used"
|
||||||
|
fi
|
||||||
|
|
||||||
|
run_podman build -t build_test $tmpdir
|
||||||
|
is "$output" ".*cache" "used cache"
|
||||||
|
|
||||||
|
run_podman build -t build_test --layers=true $tmpdir
|
||||||
|
is "$output" ".*cache" "used cache"
|
||||||
|
|
||||||
|
run_podman build -t build_test --layers=false $tmpdir
|
||||||
|
if [[ "$output" =~ "Using cache" ]]; then
|
||||||
|
is "$output" "[no instance of 'Using cache']" "no cache used"
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILDAH_LAYERS=false run_podman build -t build_test $tmpdir
|
||||||
|
if [[ "$output" =~ "Using cache" ]]; then
|
||||||
|
is "$output" "[no instance of 'Using cache']" "no cache used"
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILDAH_LAYERS=false run_podman build -t build_test --layers=1 $tmpdir
|
||||||
|
is "$output" ".*cache" "used cache"
|
||||||
|
|
||||||
|
BUILDAH_LAYERS=1 run_podman build -t build_test --layers=false $tmpdir
|
||||||
|
if [[ "$output" =~ "Using cache" ]]; then
|
||||||
|
is "$output" "[no instance of 'Using cache']" "no cache used"
|
||||||
|
fi
|
||||||
|
|
||||||
|
run_podman rmi -a --force
|
||||||
|
}
|
||||||
|
|
||||||
function teardown() {
|
function teardown() {
|
||||||
# A timeout or other error in 'build' can leave behind stale images
|
# A timeout or other error in 'build' can leave behind stale images
|
||||||
|
Reference in New Issue
Block a user