summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--].ubuntu_prepare.sh0
-rw-r--r--libpod/runtime.go2
-rw-r--r--libpod/runtime_ctr.go6
-rw-r--r--pkg/api/handlers/compat/images_build.go49
-rw-r--r--test/apiv2/10-images.at4
5 files changed, 53 insertions, 8 deletions
diff --git a/.ubuntu_prepare.sh b/.ubuntu_prepare.sh
index 1a5d1140f..1a5d1140f 100644..100755
--- a/.ubuntu_prepare.sh
+++ b/.ubuntu_prepare.sh
diff --git a/libpod/runtime.go b/libpod/runtime.go
index f4cd9cf00..58f20ef5b 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -349,7 +349,7 @@ func makeRuntime(runtime *Runtime) (retErr error) {
// it will try to use existing XDG_RUNTIME_DIR
// if current user has no write access to XDG_RUNTIME_DIR we will fail later
if err := unix.Access(runtime.storageConfig.RunRoot, unix.W_OK); err != nil {
- msg := "XDG_RUNTIME_DIR is pointing to a path which is not writable. Most likely podman will fail."
+ msg := fmt.Sprintf("RunRoot is pointing to a path (%s) which is not writable. Most likely podman will fail.", runtime.storageConfig.RunRoot)
if errors.Is(err, os.ErrNotExist) {
// if dir does not exists try to create it
if err := os.MkdirAll(runtime.storageConfig.RunRoot, 0700); err != nil {
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index 0119cb2e5..2eaa77572 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -742,7 +742,11 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force, remo
// after setting the state to ContainerStateRemoving will prevent that the container is
// restarted
if err := c.removeAllExecSessions(); err != nil {
- return err
+ if cleanupErr == nil {
+ cleanupErr = err
+ } else {
+ logrus.Errorf("Remove exec sessions: %v", err)
+ }
}
// Stop the container's storage
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go
index f0d07f492..318688222 100644
--- a/pkg/api/handlers/compat/images_build.go
+++ b/pkg/api/handlers/compat/images_build.go
@@ -119,6 +119,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
Registry string `schema:"registry"`
Rm bool `schema:"rm"`
RusageLogFile string `schema:"rusagelogfile"`
+ Remote string `schema:"remote"`
Seccomp string `schema:"seccomp"`
Secrets string `schema:"secrets"`
SecurityOpt string `schema:"securityopt"`
@@ -169,14 +170,50 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
// 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 {
- // it's not json, assume just a string
- m = []string{filepath.Join(contextDirectory, query.Dockerfile)}
+ // Tells if query paramemter `dockerfile` is set or not.
+ dockerFileSet := false
+ if utils.IsLibpodRequest(r) && query.Remote != "" {
+ // The context directory could be a URL. Try to handle that.
+ anchorDir, err := ioutil.TempDir(parse.GetTempDir(), "libpod_builder")
+ if err != nil {
+ utils.InternalServerError(w, err)
+ }
+ tempDir, subDir, err := buildahDefine.TempDirForURL(anchorDir, "buildah", query.Remote)
+ if err != nil {
+ utils.InternalServerError(w, err)
+ }
+ if tempDir != "" {
+ // We had to download it to a temporary directory.
+ // Delete it later.
+ defer func() {
+ if err = os.RemoveAll(tempDir); err != nil {
+ // We are deleting this on server so log on server end
+ // client does not have to worry about server cleanup.
+ logrus.Errorf("Cannot delete downloaded temp dir %q: %s", tempDir, err)
+ }
+ }()
+ contextDirectory = filepath.Join(tempDir, subDir)
+ } else {
+ // Nope, it was local. Use it as is.
+ absDir, err := filepath.Abs(query.Remote)
+ if err != nil {
+ utils.BadRequest(w, "remote", query.Remote, err)
+ }
+ contextDirectory = absDir
}
- containerFiles = m
} else {
+ if _, found := r.URL.Query()["dockerfile"]; found {
+ var m = []string{}
+ if err := json.Unmarshal([]byte(query.Dockerfile), &m); err != nil {
+ // it's not json, assume just a string
+ m = []string{filepath.Join(contextDirectory, query.Dockerfile)}
+ }
+ containerFiles = m
+ dockerFileSet = true
+ }
+ }
+
+ if !dockerFileSet {
containerFiles = []string{filepath.Join(contextDirectory, "Dockerfile")}
if utils.IsLibpodRequest(r) {
containerFiles = []string{filepath.Join(contextDirectory, "Containerfile")}
diff --git a/test/apiv2/10-images.at b/test/apiv2/10-images.at
index 9526183e3..a994f8e11 100644
--- a/test/apiv2/10-images.at
+++ b/test/apiv2/10-images.at
@@ -190,6 +190,10 @@ t POST "libpod/build?dockerfile=containerfile" $CONTAINERFILE_TAR application/js
t POST "build?dockerfile=containerfile" $CONTAINERFILE_TAR application/json 200 \
.stream~"STEP 1/1: FROM $IMAGE"
+# Libpod: allow building from url: https://github.com/alpinelinux/docker-alpine.git and must ignore any provided tar
+t POST "libpod/build?remote=https%3A%2F%2Fgithub.com%2Falpinelinux%2Fdocker-alpine.git" $CONTAINERFILE_TAR 200 \
+ .stream~"STEP 1/5: FROM alpine:3.14"
+
# Build api response header must contain Content-type: application/json
t POST "build?dockerfile=containerfile" $CONTAINERFILE_TAR application/json 200
response_headers=$(cat "$WORKDIR/curl.headers.out")