diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-06-09 09:28:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-09 09:28:52 -0400 |
commit | 2970e3518cc95910444903f572418f5887316e47 (patch) | |
tree | a3fc16ba6afaa54b58634a65e1b091ed198cfcf7 /pkg/api | |
parent | c75d62c9877f56f6cc6253087b75ab05b8e4eac5 (diff) | |
parent | a9cb824981db3fee6b8445b29e513c89e9b9b00b (diff) | |
download | podman-2970e3518cc95910444903f572418f5887316e47.tar.gz podman-2970e3518cc95910444903f572418f5887316e47.tar.bz2 podman-2970e3518cc95910444903f572418f5887316e47.zip |
Merge pull request #10550 from rhatdan/Dockerfile
podman-remote build should handle -f option properly
Diffstat (limited to 'pkg/api')
-rw-r--r-- | pkg/api/handlers/compat/images_build.go | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 6ff557291..50423fb96 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -139,6 +139,31 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { addCaps = m } + // convert addcaps formats + containerFiles := []string{} + if _, found := r.URL.Query()["dockerfile"]; found { + var m = []string{} + if err := json.Unmarshal([]byte(query.Dockerfile), &m); err != nil { + utils.BadRequest(w, "dockerfile", query.Dockerfile, err) + return + } + containerFiles = m + } else { + containerFiles = []string{"Dockerfile"} + if utils.IsLibpodRequest(r) { + containerFiles = []string{"Containerfile"} + if _, err = os.Stat(filepath.Join(contextDirectory, "Containerfile")); err != nil { + if _, err1 := os.Stat(filepath.Join(contextDirectory, "Dockerfile")); err1 == nil { + containerFiles = []string{"Dockerfile"} + } else { + utils.BadRequest(w, "dockerfile", query.Dockerfile, err) + } + } + } else { + containerFiles = []string{"Dockerfile"} + } + } + addhosts := []string{} if _, found := r.URL.Query()["extrahosts"]; found { if err := json.Unmarshal([]byte(query.AddHosts), &addhosts); err != nil { @@ -470,7 +495,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { runCtx, cancel := context.WithCancel(context.Background()) go func() { defer cancel() - imageID, _, err = runtime.Build(r.Context(), buildOptions, query.Dockerfile) + imageID, _, err = runtime.Build(r.Context(), buildOptions, containerFiles...) if err == nil { success = true } else { |