From b8a9b184afbc13c68d34185a60ad3dd89e6160f7 Mon Sep 17 00:00:00 2001 From: tomsweeneyredhat Date: Mon, 29 Jul 2024 16:03:36 -0400 Subject: [PATCH] Add --compat-volumes option to build and farm build Add the `--compat-volumes option from Buildah v1.37 into Podman in preparation of Podman v5.2 Signed-off-by: tomsweeneyredhat --- cmd/podman/common/build.go | 1 + docs/source/markdown/options/compat-volumes.md | 11 +++++++++++ docs/source/markdown/podman-build.1.md.in | 2 ++ docs/source/markdown/podman-farm-build.1.md.in | 2 ++ pkg/api/handlers/compat/images_build.go | 2 ++ pkg/api/server/register_images.go | 14 ++++++++++++++ pkg/bindings/images/build.go | 6 ++++++ 7 files changed, 38 insertions(+) create mode 100644 docs/source/markdown/options/compat-volumes.md diff --git a/cmd/podman/common/build.go b/cmd/podman/common/build.go index ceb8e66494..74930c1c3d 100644 --- a/cmd/podman/common/build.go +++ b/cmd/podman/common/build.go @@ -520,6 +520,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *Buil CacheTTL: cacheTTL, ConfidentialWorkload: confidentialWorkloadOptions, CommonBuildOpts: commonOpts, + CompatVolumes: types.NewOptionalBool(flags.CompatVolumes), Compression: compression, ConfigureNetwork: networkPolicy, ContextDirectory: contextDir, diff --git a/docs/source/markdown/options/compat-volumes.md b/docs/source/markdown/options/compat-volumes.md new file mode 100644 index 0000000000..16466cbaeb --- /dev/null +++ b/docs/source/markdown/options/compat-volumes.md @@ -0,0 +1,11 @@ +####> This option file is used in: +####> podman build, farm build +####> If file is edited, make sure the changes +####> are applicable to all of those. +#### **--compat-volumes** + +Handle directories marked using the VOLUME instruction (both in this build, and +those inherited from base images) such that their contents can only be modified +by ADD and COPY instructions. Any changes made in those locations by RUN +instructions will be reverted. Before the introduction of this option, this +behavior was the default, but it is now disabled by default. diff --git a/docs/source/markdown/podman-build.1.md.in b/docs/source/markdown/podman-build.1.md.in index 202cd228e1..5f647a9cf0 100644 --- a/docs/source/markdown/podman-build.1.md.in +++ b/docs/source/markdown/podman-build.1.md.in @@ -92,6 +92,8 @@ host. (Examples: arm, arm64, 386, amd64, ppc64le, s390x) @@option cgroupns.image +@@option compat-volumes + #### **--compress** This option is added to be aligned with other containers CLIs. diff --git a/docs/source/markdown/podman-farm-build.1.md.in b/docs/source/markdown/podman-farm-build.1.md.in index d8cab4ecd2..128dada676 100644 --- a/docs/source/markdown/podman-farm-build.1.md.in +++ b/docs/source/markdown/podman-farm-build.1.md.in @@ -57,6 +57,8 @@ Note: Since the images built are directly pushed to a registry, the user must pa Remove built images from farm nodes on success (Default: false). +@@option compat-volumes + @@option cpp-flag @@option cpu-period diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 03eae6030e..920882edcf 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -97,6 +97,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { CacheTo string `schema:"cacheto"` CacheTTL string `schema:"cachettl"` CgroupParent string `schema:"cgroupparent"` + CompatVolumes bool `schema:"compatvolumes"` Compression uint64 `schema:"compression"` ConfigureNetwork string `schema:"networkmode"` CPPFlags string `schema:"cppflags"` @@ -702,6 +703,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { Secrets: secrets, Volumes: query.Volumes, }, + CompatVolumes: types.NewOptionalBool(query.CompatVolumes), Compression: compression, ConfigureNetwork: parseNetworkConfigurationPolicy(query.ConfigureNetwork), ContextDirectory: contextDirectory, diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index c592eec228..02de79f4d2 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -540,6 +540,13 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // description: | // Suppress verbose build output // - in: query + // name: compatvolumes + // type: boolean + // default: false + // description: | + // Contents of base images to be modified on ADD or COPY only + // (As of version 1.37) + // - in: query // name: nocache // type: boolean // default: false @@ -1494,6 +1501,13 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // description: | // Suppress verbose build output // - in: query + // name: compatvolumes + // type: boolean + // default: false + // description: | + // Contents of base images to be modified on ADD or COPY only + // (As of version 1.37) + // - in: query // name: nocache // type: boolean // default: false diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index 58b3c25af0..1ac370aaeb 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -281,6 +281,12 @@ func Build(ctx context.Context, containerFiles []string, options types.BuildOpti if mem := options.CommonBuildOpts.Memory; mem > 0 { params.Set("memory", strconv.Itoa(int(mem))) } + switch options.CompatVolumes { + case imageTypes.OptionalBoolTrue: + params.Set("compatvolumes", "1") + case imageTypes.OptionalBoolFalse: + params.Set("compatvolumes", "0") + } if options.NoCache { params.Set("nocache", "1") }