summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat
diff options
context:
space:
mode:
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 {