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 <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2022-12-07 16:46:01 +01:00
parent 6e2e9ab227
commit 9f6cf50d52
6 changed files with 15 additions and 5 deletions

View File

@ -189,7 +189,6 @@ func buildFlags(cmd *cobra.Command) {
_ = flags.MarkHidden("signature-policy") _ = flags.MarkHidden("signature-policy")
_ = flags.MarkHidden("tls-verify") _ = flags.MarkHidden("tls-verify")
_ = flags.MarkHidden("compress") _ = flags.MarkHidden("compress")
_ = flags.MarkHidden("volume")
_ = flags.MarkHidden("output") _ = flags.MarkHidden("output")
_ = flags.MarkHidden("logsplit") _ = flags.MarkHidden("logsplit")
} }

View File

@ -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 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 bind mounts `/HOST-DIR` from the host to `/CONTAINER-DIR` in the Podman
container. (This option is not available with the remote Podman client, container.
including Mac and Windows (excluding WSL2) machines)
The `OPTIONS` are a comma-separated list and can be: <sup>[[1]](#Footnote1)</sup> The `OPTIONS` are a comma-separated list and can be: <sup>[[1]](#Footnote1)</sup>

View File

@ -138,6 +138,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
Timestamp int64 `schema:"timestamp"` Timestamp int64 `schema:"timestamp"`
Ulimits string `schema:"ulimits"` Ulimits string `schema:"ulimits"`
UnsetEnvs []string `schema:"unsetenv"` UnsetEnvs []string `schema:"unsetenv"`
Volumes []string `schema:"volume"`
}{ }{
Dockerfile: "Dockerfile", Dockerfile: "Dockerfile",
IdentityLabel: true, IdentityLabel: true,
@ -670,6 +671,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
ShmSize: strconv.Itoa(query.ShmSize), ShmSize: strconv.Itoa(query.ShmSize),
Ulimit: ulimits, Ulimit: ulimits,
Secrets: secrets, Secrets: secrets,
Volumes: query.Volumes,
}, },
Compression: compression, Compression: compression,
ConfigureNetwork: parseNetworkConfigurationPolicy(query.ConfigureNetwork), ConfigureNetwork: parseNetworkConfigurationPolicy(query.ConfigureNetwork),

View File

@ -1604,6 +1604,12 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
// type: array // type: array
// items: // items:
// type: string // type: string
// - in: query
// name: volume
// description: Extra volumes that should be mounted in the build container.
// type: array
// items:
// type: string
// produces: // produces:
// - application/json // - application/json
// responses: // responses:

View File

@ -290,6 +290,11 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
params.Add("platform", platform) params.Add("platform", platform)
} }
} }
for _, volume := range options.CommonBuildOpts.Volumes {
params.Add("volume", volume)
}
var err error var err error
var contextDir string var contextDir string
if contextDir, err = filepath.EvalSymlinks(options.ContextDirectory); err == nil { if contextDir, err = filepath.EvalSymlinks(options.ContextDirectory); err == nil {

View File

@ -196,8 +196,7 @@ skip_if_remote "secret files not implemented under podman-remote" \
"bud with containerfile env secret" \ "bud with containerfile env secret" \
"bud with containerfile env secret priority" "bud with containerfile env secret priority"
skip_if_remote "volumes don't work with podman-remote" \ skip_if_remote "--signature-policy does not work with podman-remote" \
"buildah bud --volume" \
"buildah-bud-policy" "buildah-bud-policy"
skip_if_remote "--build-context option not implemented in podman-remote" \ skip_if_remote "--build-context option not implemented in podman-remote" \