From 9f6cf50d521d70292806dbda7a422308f1b590f5 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Wed, 7 Dec 2022 16:46:01 +0100 Subject: [PATCH] podman-remote build add --volume support Just like podman-remote run users should still be able to set volumes, of course the source must be on the server machine but this is already the case for podman machine for example. Fixes #16694 Signed-off-by: Paul Holzinger --- cmd/podman/images/build.go | 1 - docs/source/markdown/podman-build.1.md.in | 3 +-- pkg/api/handlers/compat/images_build.go | 2 ++ pkg/api/server/register_images.go | 6 ++++++ pkg/bindings/images/build.go | 5 +++++ test/buildah-bud/apply-podman-deltas | 3 +-- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index 8d0135f33a..1f99110e35 100644 --- a/cmd/podman/images/build.go +++ b/cmd/podman/images/build.go @@ -189,7 +189,6 @@ func buildFlags(cmd *cobra.Command) { _ = flags.MarkHidden("signature-policy") _ = flags.MarkHidden("tls-verify") _ = flags.MarkHidden("compress") - _ = flags.MarkHidden("volume") _ = flags.MarkHidden("output") _ = flags.MarkHidden("logsplit") } diff --git a/docs/source/markdown/podman-build.1.md.in b/docs/source/markdown/podman-build.1.md.in index 011a78d059..2eba9068b1 100644 --- a/docs/source/markdown/podman-build.1.md.in +++ b/docs/source/markdown/podman-build.1.md.in @@ -767,8 +767,7 @@ using the architecture variant of the build host. Create a bind mount. Specifying the `-v /HOST-DIR:/CONTAINER-DIR` option, Podman bind mounts `/HOST-DIR` from the host to `/CONTAINER-DIR` in the Podman -container. (This option is not available with the remote Podman client, -including Mac and Windows (excluding WSL2) machines) +container. The `OPTIONS` are a comma-separated list and can be: [[1]](#Footnote1) diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 2eacbbd9e2..2d73ba527d 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -138,6 +138,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { Timestamp int64 `schema:"timestamp"` Ulimits string `schema:"ulimits"` UnsetEnvs []string `schema:"unsetenv"` + Volumes []string `schema:"volume"` }{ Dockerfile: "Dockerfile", IdentityLabel: true, @@ -670,6 +671,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { ShmSize: strconv.Itoa(query.ShmSize), Ulimit: ulimits, Secrets: secrets, + Volumes: query.Volumes, }, Compression: compression, ConfigureNetwork: parseNetworkConfigurationPolicy(query.ConfigureNetwork), diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index 50c5539d04..6aefe50066 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -1604,6 +1604,12 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // type: array // items: // type: string + // - in: query + // name: volume + // description: Extra volumes that should be mounted in the build container. + // type: array + // items: + // type: string // produces: // - application/json // responses: diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index f8552cddb3..019d108dbb 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -290,6 +290,11 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO params.Add("platform", platform) } } + + for _, volume := range options.CommonBuildOpts.Volumes { + params.Add("volume", volume) + } + var err error var contextDir string if contextDir, err = filepath.EvalSymlinks(options.ContextDirectory); err == nil { diff --git a/test/buildah-bud/apply-podman-deltas b/test/buildah-bud/apply-podman-deltas index 61db8603f9..06d69ed034 100755 --- a/test/buildah-bud/apply-podman-deltas +++ b/test/buildah-bud/apply-podman-deltas @@ -196,8 +196,7 @@ skip_if_remote "secret files not implemented under podman-remote" \ "bud with containerfile env secret" \ "bud with containerfile env secret priority" -skip_if_remote "volumes don't work with podman-remote" \ - "buildah bud --volume" \ +skip_if_remote "--signature-policy does not work with podman-remote" \ "buildah-bud-policy" skip_if_remote "--build-context option not implemented in podman-remote" \