summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-06-03 11:00:04 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-06-08 15:51:03 -0400
commita9cb824981db3fee6b8445b29e513c89e9b9b00b (patch)
tree3f5573508cd05e25044269d20f0436f4d9cfcb80 /pkg/api/handlers/compat
parent9938557a53ed6599267ed1f8c0b6378499ab8e28 (diff)
downloadpodman-a9cb824981db3fee6b8445b29e513c89e9b9b00b.tar.gz
podman-a9cb824981db3fee6b8445b29e513c89e9b9b00b.tar.bz2
podman-a9cb824981db3fee6b8445b29e513c89e9b9b00b.zip
podman-remote build should handle -f option properly
podman-remote build has to handle multiple different locations for the Containerfile. Currently this works in local mode but not when using podman-remote. Fixes: https://github.com/containers/podman/issues/9871 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r--pkg/api/handlers/compat/images_build.go27
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 {