Skip to content

build: Add support for buildkit like --mount=type=bind#3548

Merged
openshift-merge-robot merged 1 commit intocontainers:mainfrom
flouthoc:buildkit-mount-bind
Oct 6, 2021
Merged

build: Add support for buildkit like --mount=type=bind#3548
openshift-merge-robot merged 1 commit intocontainers:mainfrom
flouthoc:buildkit-mount-bind

Conversation

@flouthoc
Copy link
Copy Markdown
Collaborator

@flouthoc flouthoc commented Sep 28, 2021

Following commit adds support for using buildkit like --mount=type=bind with RUN statements.
Mounts created by --mount are transient in nature and only scoped to current RUN statements just like buildkit.

Example

FROM alpine
RUN --mount=type=bind,source=.,target=/mnt cat /mnt/input_file

PS: docs already have entry for this but it was never implemented.

Closes: #3217

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Sep 28, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@flouthoc
Copy link
Copy Markdown
Collaborator Author

@containers/buildah-maintainers @giuseppe @rhatdan @nalind @vrothberg PTAL

@flouthoc flouthoc marked this pull request as draft September 28, 2021 20:12
@flouthoc flouthoc force-pushed the buildkit-mount-bind branch 3 times, most recently from 8c78cd0 to aedfcb8 Compare September 29, 2021 07:06
@flouthoc flouthoc marked this pull request as ready for review September 29, 2021 07:08
@TomSweeneyRedHat
Copy link
Copy Markdown
Member

All kinds of test unhappiness @flouthoc

@flouthoc
Copy link
Copy Markdown
Collaborator Author

flouthoc commented Sep 29, 2021

@TomSweeneyRedHat I think its quay flakes

Edit: Some passed, some still flaky

@flouthoc flouthoc force-pushed the buildkit-mount-bind branch 3 times, most recently from 084a36c to dbe2b46 Compare September 30, 2021 08:42
@flouthoc
Copy link
Copy Markdown
Collaborator Author

resolved conflicts after recent commits in main

@flouthoc flouthoc force-pushed the buildkit-mount-bind branch from 5ad284f to 62c1da3 Compare October 1, 2021 07:22
@flouthoc
Copy link
Copy Markdown
Collaborator Author

flouthoc commented Oct 1, 2021

@cevich @containers/buildah-maintainers I am not sure but looks like something is up with CI for Conformance test its failing for all the PR's with error Package containerd.io is not installed

@cevich
Copy link
Copy Markdown
Member

cevich commented Oct 1, 2021

Opened #3560 to fix CI

@flouthoc flouthoc force-pushed the buildkit-mount-bind branch from 1343155 to 0d686e8 Compare October 1, 2021 19:33
@flouthoc
Copy link
Copy Markdown
Collaborator Author

flouthoc commented Oct 1, 2021

@nalind Added requested tests, I still need to implement rw for chroot isolation.

@flouthoc flouthoc force-pushed the buildkit-mount-bind branch from 0d686e8 to ba9e00c Compare October 1, 2021 21:14
@flouthoc
Copy link
Copy Markdown
Collaborator Author

flouthoc commented Oct 1, 2021

@nalind I think rw is already working properly for isolated chroot i have also written a test for rw on isolated chroot. With rw enabled user can write on bind files and changes are also reflected on host.

@flouthoc flouthoc force-pushed the buildkit-mount-bind branch from ba9e00c to 178f86b Compare October 1, 2021 21:20
@flouthoc flouthoc requested a review from nalind October 1, 2021 21:20
@flouthoc flouthoc force-pushed the buildkit-mount-bind branch 2 times, most recently from f27ab79 to 11f7f93 Compare October 1, 2021 21:25
@flouthoc
Copy link
Copy Markdown
Collaborator Author

flouthoc commented Oct 1, 2021

Rebasing after #3562

@rhatdan
Copy link
Copy Markdown
Member

rhatdan commented Oct 4, 2021

LGTM

@flouthoc flouthoc force-pushed the buildkit-mount-bind branch 2 times, most recently from 6f01322 to 63a27a3 Compare October 6, 2021 06:02
Following commit adds support for using buildkit like
`--mount=type=bind` with `RUN` statements. Mounts created by `--mount`
are transient in nature and only scoped to current RUN statements.

Signed-off-by: Aditya Rajan <arajan@redhat.com>
@flouthoc flouthoc force-pushed the buildkit-mount-bind branch from 63a27a3 to f0d3140 Compare October 6, 2021 08:16
// Alias for "ro"
newMount.Options = append(newMount.Options, "ro")
case "shared", "rshared", "private", "rprivate", "slave", "rslave", "Z", "z":
case "shared", "rshared", "private", "rprivate", "slave", "rslave", "Z", "z", "U":
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have test coverage for the "U" flag when used here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nalind Mount code is being reused from volumes and tests for U is already added here https://github.com/containers/buildah/blob/main/tests/run.bats#L304 therefore I refrained from adding ownership test to prevent redundancy

@nalind
Copy link
Copy Markdown
Member

nalind commented Oct 6, 2021

Question about test coverage of the "U" flag, otherwise LGTM.

@flouthoc flouthoc requested a review from nalind October 6, 2021 18:03
@rhatdan
Copy link
Copy Markdown
Member

rhatdan commented Oct 6, 2021

/lgtm

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RUN --mount=type=bind doesn't seem to work with relative source paths

6 participants