Support pulling Dockerfile from http

Currently podman build http://remote.com/Dockerfile does not work.
podman always treats this file as an Archive.

Vendoring in the latest buildah code fixes this issue.  Also updated
the man pages to better explain the syntax.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #775
Approved by: TomSweeneyRedHat
This commit is contained in:
Daniel J Walsh
2018-05-15 17:29:09 -04:00
committed by Atomic Bot
parent 1aaf8df5be
commit 9fcc475d03
7 changed files with 64 additions and 29 deletions

View File

@ -22,7 +22,7 @@ const (
Package = "buildah"
// Version for the Package. Bump version in contrib/rpm/buildah.spec
// too.
Version = "0.16"
Version = "1.0"
// The value we use to identify what type of information, currently a
// serialized Builder structure, we are using as per-container state.
// This should only be changed when we make incompatible changes to

View File

@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"github.com/containers/storage/pkg/chrootarchive"
@ -34,7 +35,23 @@ func downloadToDirectory(url, dir string) error {
if resp.ContentLength == 0 {
return errors.Errorf("no contents in %q", url)
}
return chrootarchive.Untar(resp.Body, dir, nil)
if err := chrootarchive.Untar(resp.Body, dir, nil); err != nil {
resp1, err := http.Get(url)
if err != nil {
return errors.Wrapf(err, "error getting %q", url)
}
defer resp1.Body.Close()
body, err := ioutil.ReadAll(resp1.Body)
if err != nil {
return errors.Wrapf(err, "Failed to read %q", url)
}
dockerfile := filepath.Join(dir, "Dockerfile")
// Assume this is a Dockerfile
if err := ioutil.WriteFile(dockerfile, body, 0600); err != nil {
return errors.Wrapf(err, "Failed to write %q to %q", url, dockerfile)
}
}
return nil
}
// TempDirForURL checks if the passed-in string looks like a URL. If it is,

View File

@ -19,6 +19,10 @@ var (
Name: "build-arg",
Usage: "`argument=value` to supply to the builder",
},
cli.StringFlag{
Name: "cache-from",
Usage: "Images to utilise as potential cache sources. Buildah does not currently support caching so this is a NOOP.",
},
cli.StringFlag{
Name: "cert-dir",
Value: "",
@ -37,6 +41,10 @@ var (
Name: "file, f",
Usage: "`pathname or URL` of a Dockerfile",
},
cli.BoolFlag{
Name: "force-rm",
Usage: "Always remove intermediate containers after a build. Buildah does not currently support caching so this is a NOOP.",
},
cli.StringFlag{
Name: "format",
Usage: "`format` of the built image's manifest and metadata",
@ -45,6 +53,10 @@ var (
Name: "iidfile",
Usage: "Write the image ID to the file",
},
cli.BoolFlag{
Name: "no-cache",
Usage: "Do not use caching for the container build. Buildah does not currently support caching so this is a NOOP.",
},
cli.BoolTFlag{
Name: "pull",
Usage: "pull the image if not present",
@ -59,7 +71,7 @@ var (
},
cli.BoolFlag{
Name: "rm",
Usage: "Remove intermediate containers after a successful build. Buildah does not currently support cacheing so this is a NOOP.",
Usage: "Remove intermediate containers after a successful build. Buildah does not currently support caching so this is a NOOP.",
},
cli.StringFlag{
Name: "runtime",
@ -76,7 +88,7 @@ var (
},
cli.BoolFlag{
Name: "squash",
Usage: "Squash newly built layers into a single new layer. Buildah does not currently support cacheing so this is a NOOP.",
Usage: "Squash newly built layers into a single new layer. Buildah does not currently support caching so this is a NOOP.",
},
cli.StringSliceFlag{
Name: "tag, t",
@ -106,7 +118,7 @@ var (
Usage: "limit the CPU CFS (Completely Fair Scheduler) quota",
},
cli.Uint64Flag{
Name: "cpu-shares",
Name: "cpu-shares, c",
Usage: "CPU shares (relative weight)",
},
cli.StringFlag{

View File

@ -180,9 +180,9 @@ func validateVolumeOpts(option string) error {
return errors.Errorf("invalid options %q, can only specify 1 'z' or 'Z' option", option)
}
foundLabelChange++
case "private", "rprivate", "shared", "rshared", "slave", "rslave":
case "private", "rprivate", "shared", "rshared", "slave", "rslave", "unbindable", "runbindable":
if foundRootPropagation > 1 {
return errors.Errorf("invalid options %q, can only specify 1 '[r]shared', '[r]private' or '[r]slave' option", option)
return errors.Errorf("invalid options %q, can only specify 1 '[r]shared', '[r]private', '[r]slave' or '[r]unbindable' option", option)
}
foundRootPropagation++
default:

View File

@ -326,15 +326,7 @@ func (b *Builder) Run(command []string, options RunOptions) error {
if len(command) > 0 {
g.SetProcessArgs(command)
} else {
cmd := b.Cmd()
if len(options.Cmd) > 0 {
cmd = options.Cmd
}
entrypoint := b.Entrypoint()
if len(options.Entrypoint) > 0 {
entrypoint = options.Entrypoint
}
g.SetProcessArgs(append(entrypoint, cmd...))
g.SetProcessArgs(nil)
}
if options.WorkingDir != "" {
g.SetProcessCwd(options.WorkingDir)