diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-02-14 15:40:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-14 15:40:52 +0100 |
commit | 0cd22435964573231ab32e545d5f319821b35b14 (patch) | |
tree | 4325f9e495b6761b64d984ec32ebf0c8b9cca185 /libpod/adapter/runtime.go | |
parent | dfc64e15d7f8b1715798fd68bd3ff74ae192b354 (diff) | |
parent | ef85dd7950800fdce9ab58724921507cba31004b (diff) | |
download | podman-0cd22435964573231ab32e545d5f319821b35b14.tar.gz podman-0cd22435964573231ab32e545d5f319821b35b14.tar.bz2 podman-0cd22435964573231ab32e545d5f319821b35b14.zip |
Merge pull request #2321 from baude/remotebuild
podman-remote build
Diffstat (limited to 'libpod/adapter/runtime.go')
-rw-r--r-- | libpod/adapter/runtime.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/libpod/adapter/runtime.go b/libpod/adapter/runtime.go index 7dd845616..3146cf5db 100644 --- a/libpod/adapter/runtime.go +++ b/libpod/adapter/runtime.go @@ -9,6 +9,9 @@ import ( "os" "strconv" + "github.com/containers/buildah" + "github.com/containers/buildah/imagebuildah" + "github.com/containers/buildah/pkg/parse" "github.com/containers/image/docker/reference" "github.com/containers/image/types" "github.com/containers/libpod/cmd/podman/cliconfig" @@ -254,3 +257,51 @@ func libpodVolumeToVolume(volumes []*libpod.Volume) []*Volume { } return vols } + +// Build is the wrapper to build images +func (r *LocalRuntime) Build(ctx context.Context, c *cliconfig.BuildValues, options imagebuildah.BuildOptions, dockerfiles []string) error { + namespaceOptions, networkPolicy, err := parse.NamespaceOptions(c.PodmanCommand.Command) + if err != nil { + return errors.Wrapf(err, "error parsing namespace-related options") + } + usernsOption, idmappingOptions, err := parse.IDMappingOptions(c.PodmanCommand.Command) + if err != nil { + return errors.Wrapf(err, "error parsing ID mapping options") + } + namespaceOptions.AddOrReplace(usernsOption...) + + systemContext, err := parse.SystemContextFromOptions(c.PodmanCommand.Command) + if err != nil { + return errors.Wrapf(err, "error building system context") + } + + authfile := c.Authfile + if len(c.Authfile) == 0 { + authfile = os.Getenv("REGISTRY_AUTH_FILE") + } + + systemContext.AuthFilePath = authfile + commonOpts, err := parse.CommonBuildOptions(c.PodmanCommand.Command) + if err != nil { + return err + } + + options.NamespaceOptions = namespaceOptions + options.ConfigureNetwork = networkPolicy + options.IDMappingOptions = idmappingOptions + options.CommonBuildOpts = commonOpts + options.SystemContext = systemContext + + if c.Flag("runtime").Changed { + options.Runtime = r.GetOCIRuntimePath() + } + if c.Quiet { + options.ReportWriter = ioutil.Discard + } + + if rootless.IsRootless() { + options.Isolation = buildah.IsolationOCIRootless + } + + return r.Runtime.Build(ctx, options, dockerfiles...) +} |