diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2021-06-03 11:00:04 -0400 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2021-06-11 11:14:04 -0400 |
commit | 2afb5eeab672f6b10cda78f4d6bc152cf1e9a769 (patch) | |
tree | a1ec0fb70cbeae255954596c967e2a3dbaacb4e7 /pkg/api/handlers/compat/images_build.go | |
parent | 6beae86f014ceb1ad2f0a33b626b7881bf17e419 (diff) | |
download | podman-2afb5eeab672f6b10cda78f4d6bc152cf1e9a769.tar.gz podman-2afb5eeab672f6b10cda78f4d6bc152cf1e9a769.tar.bz2 podman-2afb5eeab672f6b10cda78f4d6bc152cf1e9a769.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/images_build.go')
-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 { |