aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-08-28 09:39:47 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-29 14:27:11 +0000
commiteb5fdebc84e59f8645218f8fdfd6e6a8136cfa43 (patch)
treeb1625395d2cb3ca26ba85c3e418ce36edcea27af
parent6a46af571e70fd49655fe97df93391500933b2d1 (diff)
downloadpodman-eb5fdebc84e59f8645218f8fdfd6e6a8136cfa43.tar.gz
podman-eb5fdebc84e59f8645218f8fdfd6e6a8136cfa43.tar.bz2
podman-eb5fdebc84e59f8645218f8fdfd6e6a8136cfa43.zip
Vendor in latest projectatomic/buildah
This will help document the defaults in podman build. podman build --help will now show the defaults and mention the environment variables that can be set to change them. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #1364 Approved by: mheon
-rw-r--r--cmd/podman/build.go13
-rw-r--r--cmd/podman/common.go13
-rw-r--r--docs/podman-build.1.md15
-rw-r--r--pkg/varlinkapi/images.go4
-rw-r--r--vendor.conf2
-rw-r--r--vendor/github.com/projectatomic/buildah/buildah.go4
-rw-r--r--vendor/github.com/projectatomic/buildah/common.go7
-rw-r--r--vendor/github.com/projectatomic/buildah/config.go33
-rw-r--r--vendor/github.com/projectatomic/buildah/imagebuildah/build.go11
-rw-r--r--vendor/github.com/projectatomic/buildah/new.go1
-rw-r--r--vendor/github.com/projectatomic/buildah/pkg/cli/common.go32
11 files changed, 101 insertions, 34 deletions
diff --git a/cmd/podman/build.go b/cmd/podman/build.go
index e35fd10a4..6671c18c7 100644
--- a/cmd/podman/build.go
+++ b/cmd/podman/build.go
@@ -77,16 +77,9 @@ func buildCmd(c *cli.Context) error {
}
dockerfiles := getDockerfiles(c.StringSlice("file"))
- format := "oci"
- if c.IsSet("format") {
- format = strings.ToLower(c.String("format"))
- }
- if strings.HasPrefix(format, "oci") {
- format = imagebuildah.OCIv1ImageFormat
- } else if strings.HasPrefix(format, "docker") {
- format = imagebuildah.Dockerv2ImageFormat
- } else {
- return errors.Errorf("unrecognized image type %q", format)
+ format, err := getFormat(c)
+ if err != nil {
+ return nil
}
contextDir := ""
cliArgs := c.Args()
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index d9216850f..797e74c98 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -10,6 +10,7 @@ import (
"github.com/containers/storage"
"github.com/fatih/camelcase"
"github.com/pkg/errors"
+ "github.com/projectatomic/buildah"
"github.com/urfave/cli"
)
@@ -406,3 +407,15 @@ var createFlags = []cli.Flag{
Usage: "Working `directory inside the container",
},
}
+
+func getFormat(c *cli.Context) (string, error) {
+ format := strings.ToLower(c.String("format"))
+ if strings.HasPrefix(format, buildah.OCI) {
+ return buildah.OCIv1ImageManifest, nil
+ }
+
+ if strings.HasPrefix(format, buildah.DOCKER) {
+ return buildah.Dockerv2ImageManifest, nil
+ }
+ return "", errors.Errorf("unrecognized image type %q", format)
+}
diff --git a/docs/podman-build.1.md b/docs/podman-build.1.md
index 31c85d13f..7e8f0c137 100644
--- a/docs/podman-build.1.md
+++ b/docs/podman-build.1.md
@@ -194,6 +194,9 @@ Control the format for the built image's manifest and configuration data.
Recognized formats include *oci* (OCI image-spec v1.0, the default) and
*docker* (version 2, using schema format 2 for the manifest).
+Note: You can also override the default format by setting the BUILDAH\_FORMAT
+environment variable. `export BUILDAH_FORMAT=docker`
+
**--iidfile** *ImageIDfile*
Write the image ID to the file.
@@ -229,7 +232,7 @@ Add an image *label* (e.g. label=*value*) to the image metadata. Can be used mul
Cache intermediate images during the build process (Default is `false`).
-Note: You can also override the default value of layers by setting the BUILDAH_LAYERS
+Note: You can also override the default value of layers by setting the BUILDAH\_LAYERS
environment variable. `export BUILDAH_LAYERS=true`
**--logfile** *filename*
@@ -305,11 +308,15 @@ Remove intermediate containers after a successful build (default true).
The *path* to an alternate OCI-compatible runtime, which will be used to run
commands specified by the **RUN** instruction.
+Note: You can also override the default runtime by setting the BUILDAH\_RUNTIME
+environment variable. `export BUILDAH_RUNTIME=/usr/local/bin/runc`
+
**--runtime-flag** *flag*
Adds global flags for the container rutime. To list the supported flags, please
consult the manpages of the selected container runtime (`runc` is the default
runtime, the manpage to consult is `runc(8)`).
+
Note: Do not pass the leading `--` to the flag. To pass the runc flag `--log-format json`
to podman build, the option given would be `--runtime-flag log-format=json`.
@@ -536,13 +543,13 @@ podman build -f Dockerfile.simple .
cat ~/Dockerfile | podman build -f - .
-podman build -f Dockerfile.simple -f Dockerfile.notsosimple
+podman build -f Dockerfile.simple -f Dockerfile.notsosimple .
podman build -f Dockerfile.in ~
podman build -t imageName .
-podman build --tls-verify=true -t imageName -f Dockerfile.simple
+podman build --tls-verify=true -t imageName -f Dockerfile.simple .
podman build --tls-verify=false -t imageName .
@@ -550,7 +557,7 @@ podman build --runtime-flag log-format=json .
podman build --runtime-flag debug .
-podman build --authfile /tmp/auths/myauths.json --cert-dir ~/auth --tls-verify=true --creds=username:password -t imageName -f Dockerfile.simple
+podman build --authfile /tmp/auths/myauths.json --cert-dir ~/auth --tls-verify=true --creds=username:password -t imageName -f Dockerfile.simple .
podman build --memory 40m --cpu-period 10000 --cpu-quota 50000 --ulimit nofile=1024:1028 -t imageName .
diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go
index 174225953..3cd2b879a 100644
--- a/pkg/varlinkapi/images.go
+++ b/pkg/varlinkapi/images.go
@@ -133,9 +133,9 @@ func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildI
}
if strings.HasPrefix(manifestType, "oci") {
- manifestType = imagebuildah.OCIv1ImageFormat
+ manifestType = buildah.OCIv1ImageManifest
} else if strings.HasPrefix(manifestType, "docker") {
- manifestType = imagebuildah.Dockerv2ImageFormat
+ manifestType = buildah.Dockerv2ImageManifest
} else {
return call.ReplyErrorOccurred(fmt.Sprintf("unrecognized image type %q", manifestType))
}
diff --git a/vendor.conf b/vendor.conf
index 4aba4cb22..c97aa4145 100644
--- a/vendor.conf
+++ b/vendor.conf
@@ -90,7 +90,7 @@ k8s.io/kube-openapi 275e2ce91dec4c05a4094a7b1daee5560b555ac9 https://github.com/
k8s.io/utils 258e2a2fa64568210fbd6267cf1d8fd87c3cb86e https://github.com/kubernetes/utils
github.com/mrunalp/fileutils master
github.com/varlink/go master
-github.com/projectatomic/buildah 745bf7e56bda740ce7cfc55318da08529e5ed519
+github.com/projectatomic/buildah 2423a90e23ced88c72e30664631af18c9af75148
github.com/Nvveen/Gotty master
github.com/fsouza/go-dockerclient master
github.com/openshift/imagebuilder master
diff --git a/vendor/github.com/projectatomic/buildah/buildah.go b/vendor/github.com/projectatomic/buildah/buildah.go
index 32785a26f..60688b372 100644
--- a/vendor/github.com/projectatomic/buildah/buildah.go
+++ b/vendor/github.com/projectatomic/buildah/buildah.go
@@ -178,6 +178,8 @@ type Builder struct {
CommonBuildOpts *CommonBuildOptions
// TopLayer is the top layer of the image
TopLayer string
+ // Format for the build Image
+ Format string
}
// BuilderInfo are used as objects to display container information
@@ -360,6 +362,8 @@ type BuilderOptions struct {
DropCapabilities []string
CommonBuildOpts *CommonBuildOptions
+ // Format for the container image
+ Format string
}
// ImportOptions are used to initialize a Builder from an existing container
diff --git a/vendor/github.com/projectatomic/buildah/common.go b/vendor/github.com/projectatomic/buildah/common.go
index 18c960003..dcf922dc9 100644
--- a/vendor/github.com/projectatomic/buildah/common.go
+++ b/vendor/github.com/projectatomic/buildah/common.go
@@ -7,6 +7,13 @@ import (
"github.com/containers/image/types"
)
+const (
+ // OCI used to define the "oci" image format
+ OCI = "oci"
+ // DOCKER used to define the "docker" image format
+ DOCKER = "docker"
+)
+
func getCopyOptions(reportWriter io.Writer, sourceSystemContext *types.SystemContext, destinationSystemContext *types.SystemContext, manifestType string) *cp.Options {
return &cp.Options{
ReportWriter: reportWriter,
diff --git a/vendor/github.com/projectatomic/buildah/config.go b/vendor/github.com/projectatomic/buildah/config.go
index 731e3b80a..2f4d8319a 100644
--- a/vendor/github.com/projectatomic/buildah/config.go
+++ b/vendor/github.com/projectatomic/buildah/config.go
@@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"os"
- "path/filepath"
"runtime"
"strings"
"time"
@@ -12,9 +11,11 @@ import (
"github.com/containers/image/manifest"
"github.com/containers/image/transports"
"github.com/containers/image/types"
+ "github.com/containers/storage/pkg/stringid"
ociv1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/projectatomic/buildah/docker"
+ "github.com/sirupsen/logrus"
)
// unmarshalConvertedConfig obtains the config blob of img valid for the wantedManifestMIMEType format
@@ -107,8 +108,8 @@ func (b *Builder) fixupConfig() {
if b.Architecture() == "" {
b.SetArchitecture(runtime.GOARCH)
}
- if b.WorkDir() == "" {
- b.SetWorkDir(string(filepath.Separator))
+ if b.Format == Dockerv2ImageManifest && b.Hostname() == "" {
+ b.SetHostname(stringid.TruncateID(stringid.GenerateRandomID()))
}
}
@@ -218,6 +219,9 @@ func (b *Builder) ClearOnBuild() {
// Note: this setting is not present in the OCIv1 image format, so it is
// discarded when writing images using OCIv1 formats.
func (b *Builder) SetOnBuild(onBuild string) {
+ if onBuild != "" && b.Format != Dockerv2ImageManifest {
+ logrus.Errorf("ONBUILD is not supported for OCI Image formats, %s will be ignored. Must use `docker` format", onBuild)
+ }
b.Docker.Config.OnBuild = append(b.Docker.Config.OnBuild, onBuild)
}
@@ -247,6 +251,10 @@ func (b *Builder) Shell() []string {
// Note: this setting is not present in the OCIv1 image format, so it is
// discarded when writing images using OCIv1 formats.
func (b *Builder) SetShell(shell []string) {
+ if len(shell) > 0 && b.Format != Dockerv2ImageManifest {
+ logrus.Errorf("SHELL is not supported for OCI Image format, %s will be ignored. Must use `docker` format", shell)
+ }
+
b.Docker.Config.Shell = copyStringSlice(shell)
}
@@ -327,7 +335,10 @@ func (b *Builder) SetCmd(cmd []string) {
// Entrypoint returns the command to be run for containers built from images
// built from this container.
func (b *Builder) Entrypoint() []string {
- return copyStringSlice(b.OCIv1.Config.Entrypoint)
+ if len(b.OCIv1.Config.Entrypoint) > 0 {
+ return copyStringSlice(b.OCIv1.Config.Entrypoint)
+ }
+ return nil
}
// SetEntrypoint sets the command to be run for in containers built from images
@@ -416,7 +427,10 @@ func (b *Builder) Volumes() []string {
for k := range b.OCIv1.Config.Volumes {
v = append(v, k)
}
- return v
+ if len(v) > 0 {
+ return v
+ }
+ return nil
}
// AddVolume adds a location to the image's list of locations which should be
@@ -460,6 +474,9 @@ func (b *Builder) Hostname() string {
// Note: this setting is not present in the OCIv1 image format, so it is
// discarded when writing images using OCIv1 formats.
func (b *Builder) SetHostname(name string) {
+ if name != "" && b.Format != Dockerv2ImageManifest {
+ logrus.Errorf("HOSTNAME is not supported for OCI Image format, hostname %s will be ignored. Must use `docker` format", name)
+ }
b.Docker.Config.Hostname = name
}
@@ -474,6 +491,9 @@ func (b *Builder) Domainname() string {
// Note: this setting is not present in the OCIv1 image format, so it is
// discarded when writing images using OCIv1 formats.
func (b *Builder) SetDomainname(name string) {
+ if name != "" && b.Format != Dockerv2ImageManifest {
+ logrus.Errorf("DOMAINNAME is not supported for OCI Image format, domainname %s will be ignored. Must use `docker` format", name)
+ }
b.Docker.Config.Domainname = name
}
@@ -493,6 +513,9 @@ func (b *Builder) Comment() string {
// Note: this setting is not present in the OCIv1 image format, so it is
// discarded when writing images using OCIv1 formats.
func (b *Builder) SetComment(comment string) {
+ if comment != "" && b.Format != Dockerv2ImageManifest {
+ logrus.Errorf("COMMENT is not supported for OCI Image format, comment %s will be ignored. Must use `docker` format", comment)
+ }
b.Docker.Comment = comment
}
diff --git a/vendor/github.com/projectatomic/buildah/imagebuildah/build.go b/vendor/github.com/projectatomic/buildah/imagebuildah/build.go
index 52bbe9d8c..08d0f6268 100644
--- a/vendor/github.com/projectatomic/buildah/imagebuildah/build.go
+++ b/vendor/github.com/projectatomic/buildah/imagebuildah/build.go
@@ -34,11 +34,9 @@ import (
)
const (
- PullIfMissing = buildah.PullIfMissing
- PullAlways = buildah.PullAlways
- PullNever = buildah.PullNever
- OCIv1ImageFormat = buildah.OCIv1ImageManifest
- Dockerv2ImageFormat = buildah.Dockerv2ImageManifest
+ PullIfMissing = buildah.PullIfMissing
+ PullAlways = buildah.PullAlways
+ PullNever = buildah.PullNever
Gzip = archive.Gzip
Bzip2 = archive.Bzip2
@@ -114,7 +112,7 @@ type BuildOptions struct {
ReportWriter io.Writer
// OutputFormat is the format of the output image's manifest and
// configuration data.
- // Accepted values are OCIv1ImageFormat and Dockerv2ImageFormat.
+ // Accepted values are buildah.OCIv1ImageManifest and buildah.Dockerv2ImageManifest.
OutputFormat string
// SystemContext holds parameters used for authentication.
SystemContext *types.SystemContext
@@ -640,6 +638,7 @@ func (b *Executor) Prepare(ctx context.Context, ib *imagebuilder.Builder, node *
IDMappingOptions: b.idmappingOptions,
CommonBuildOpts: b.commonBuildOptions,
DefaultMountsFilePath: b.defaultMountsFilePath,
+ Format: b.outputFormat,
}
builder, err := buildah.NewBuilder(ctx, b.store, builderOptions)
if err != nil {
diff --git a/vendor/github.com/projectatomic/buildah/new.go b/vendor/github.com/projectatomic/buildah/new.go
index 773e65427..1abb2f1f1 100644
--- a/vendor/github.com/projectatomic/buildah/new.go
+++ b/vendor/github.com/projectatomic/buildah/new.go
@@ -339,6 +339,7 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions
CommonBuildOpts: options.CommonBuildOpts,
TopLayer: topLayer,
Args: options.Args,
+ Format: options.Format,
}
if options.Mount {
diff --git a/vendor/github.com/projectatomic/buildah/pkg/cli/common.go b/vendor/github.com/projectatomic/buildah/pkg/cli/common.go
index 39a1773e4..0d035f471 100644
--- a/vendor/github.com/projectatomic/buildah/pkg/cli/common.go
+++ b/vendor/github.com/projectatomic/buildah/pkg/cli/common.go
@@ -10,12 +10,12 @@ import (
"strings"
"github.com/opencontainers/runtime-spec/specs-go"
+ "github.com/projectatomic/buildah"
"github.com/projectatomic/buildah/util"
"github.com/urfave/cli"
)
var (
- runtime = util.Runtime()
usernsFlags = []cli.Flag{
cli.StringFlag{
Name: "userns",
@@ -113,7 +113,8 @@ var (
},
cli.StringFlag{
Name: "format",
- Usage: "`format` of the built image's manifest and metadata",
+ Usage: "`format` of the built image's manifest and metadata. Use BUILDAH_FORMAT environment variable to override.",
+ Value: DefaultFormat(),
},
cli.StringFlag{
Name: "iidfile",
@@ -121,7 +122,8 @@ var (
},
cli.StringFlag{
Name: "isolation",
- Usage: "`type` of process isolation to use",
+ Usage: "`type` of process isolation to use. Use BUILDAH_ISOLATION environment variable to override.",
+ Value: DefaultIsolation(),
},
cli.StringSliceFlag{
Name: "label",
@@ -129,7 +131,7 @@ var (
},
cli.BoolFlag{
Name: "layers",
- Usage: fmt.Sprintf("cache intermediate layers during build (default %t)", UseLayers()),
+ Usage: fmt.Sprintf("cache intermediate layers during build. Use BUILDAH_LAYERS environment variable to override. (default %t)", UseLayers()),
},
cli.BoolFlag{
Name: "no-cache",
@@ -161,8 +163,8 @@ var (
},
cli.StringFlag{
Name: "runtime",
- Usage: "`path` to an alternate runtime",
- Value: runtime,
+ Usage: "`path` to an alternate runtime. Use BUILDAH_RUNTIME environment variable to override.",
+ Value: util.Runtime(),
},
cli.StringSliceFlag{
Name: "runtime-flag",
@@ -260,3 +262,21 @@ func UseLayers() bool {
}
return false
}
+
+// DefaultFormat returns the default image format
+func DefaultFormat() string {
+ format := os.Getenv("BUILDAH_FORMAT")
+ if format != "" {
+ return format
+ }
+ return buildah.OCI
+}
+
+// DefaultIsolation returns the default image format
+func DefaultIsolation() string {
+ isolation := os.Getenv("BUILDAH_ISOLATION")
+ if isolation != "" {
+ return isolation
+ }
+ return buildah.OCI
+}