summaryrefslogtreecommitdiff
path: root/cmd/podman/build.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-09-06 16:10:06 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-09-07 12:57:09 +0000
commitd92650a922fa82852d6f3310eff24e6b8a93fb03 (patch)
treea4430220fe8529b7cfd29685c36472616b48db54 /cmd/podman/build.go
parent782caea8015679e5d67d15b9562488da06cdfcd5 (diff)
downloadpodman-d92650a922fa82852d6f3310eff24e6b8a93fb03.tar.gz
podman-d92650a922fa82852d6f3310eff24e6b8a93fb03.tar.bz2
podman-d92650a922fa82852d6f3310eff24e6b8a93fb03.zip
use layer cache when building images
to more closely mimic docker default behavior, the --layers cli option is set to true by default for podman. the buildah environment variable of BUILDAH_LAYERS is still honored and will override the command line input. this should be considered in place of PR #1383. Many thanks for Scott McCarty for inspiring this welcome change. Signed-off-by: baude <bbaude@redhat.com> Closes: #1422 Approved by: rhatdan
Diffstat (limited to 'cmd/podman/build.go')
-rw-r--r--cmd/podman/build.go26
1 files changed, 19 insertions, 7 deletions
diff --git a/cmd/podman/build.go b/cmd/podman/build.go
index d229cde03..0ca0b3d83 100644
--- a/cmd/podman/build.go
+++ b/cmd/podman/build.go
@@ -1,11 +1,6 @@
package main
import (
- "io/ioutil"
- "os"
- "path/filepath"
- "strings"
-
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
@@ -15,16 +10,26 @@ import (
"github.com/projectatomic/buildah/pkg/parse"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
)
var (
+ layerFlags = []cli.Flag{
+ cli.BoolTFlag{
+ Name: "layers",
+ Usage: "cache intermediate layers during build. Use BUILDAH_LAYERS environment variable to override. ",
+ },
+ }
buildDescription = "Builds an OCI or Docker image using instructions from one\n" +
"or more Dockerfiles and a specified build context directory."
buildCommand = cli.Command{
Name: "build",
Usage: "Build an image using instructions from Dockerfiles",
Description: buildDescription,
- Flags: append(buildahcli.BudFlags, buildahcli.FromAndBudFlags...),
+ Flags: append(append(buildahcli.BudFlags, layerFlags...), buildahcli.FromAndBudFlags...),
Action: buildCmd,
ArgsUsage: "CONTEXT-DIRECTORY | URL",
SkipArgReorder: true,
@@ -84,6 +89,13 @@ func buildCmd(c *cli.Context) error {
}
contextDir := ""
cliArgs := c.Args()
+
+ layers := c.BoolT("layers") // layers for podman defaults to true
+ // Check to see if the BUILDAH_LAYERS environment variable is set and override command-line
+ if _, ok := os.LookupEnv("BUILDAH_LAYERS"); ok {
+ layers = buildahcli.UseLayers()
+ }
+
if len(cliArgs) > 0 {
// The context directory could be a URL. Try to handle that.
tempDir, subDir, err := imagebuildah.TempDirForURL("", "buildah", cliArgs[0])
@@ -215,7 +227,7 @@ func buildCmd(c *cli.Context) error {
Squash: c.Bool("squash"),
Labels: c.StringSlice("label"),
Annotations: c.StringSlice("annotation"),
- Layers: c.Bool("layers"),
+ Layers: layers,
NoCache: c.Bool("no-cache"),
RemoveIntermediateCtrs: c.BoolT("rm"),
ForceRmIntermediateCtrs: c.Bool("force-rm"),