Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stage_executor: Add support for inline FROM --platform= within Containerfile/Dockerfile #3757

Merged

Conversation

flouthoc
Copy link
Collaborator

@flouthoc flouthoc commented Jan 31, 2022

See: https://docs.docker.com/engine/reference/builder/#from

Allows end users to configure executor's OS, ARCH,VARIANT via inline --platform.

Usage

 FROM --platform=linux/arm64 alpine
 RUN uname -a

While this allows executor to pull base images with custom
OS, ARCH, VARIANT it still allows end-users to tag images with
different format if they need to.

For example

Doing a buildah build --platform linux/amd64 -t test . on below containerfile.

FROM --platform=linux/arm64 alpine
RUN uname -a

Would result in tagging image as linux/amd64 while base layer would
be pulled for linux/arm64.

Closes: #3712
Closes: #3261

@flouthoc
Copy link
Collaborator Author

Please don't review this PR yet as this PR is a implementation of : openshift/imagebuilder#212 so lets wait for that.

@flouthoc flouthoc force-pushed the buildkit-platform-attemp-2 branch from 64fe2b2 to 26eab2e Compare January 31, 2022 11:34
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 3, 2022
@flouthoc flouthoc force-pushed the buildkit-platform-attemp-2 branch from 26eab2e to 4a6cf8b Compare February 3, 2022 08:47
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 3, 2022
@flouthoc flouthoc marked this pull request as ready for review February 3, 2022 08:47
@flouthoc
Copy link
Collaborator Author

flouthoc commented Feb 3, 2022

@nalind @rhatdan PTAL. Also modified tests to also check if qemu-user-static is already there on platform as @edsantiago suggested in the last PR.

@flouthoc
Copy link
Collaborator Author

flouthoc commented Feb 3, 2022

This PR closes two existing open issues.

@flouthoc flouthoc force-pushed the buildkit-platform-attemp-2 branch 2 times, most recently from c42db9f to 212b6fb Compare February 3, 2022 10:21
@flouthoc flouthoc requested review from nalind and rhatdan February 3, 2022 11:49
@rhatdan
Copy link
Member

rhatdan commented Feb 3, 2022

LGTM
@nalind @vrothberg @TomSweeneyRedHat @ashley-cui @umohnani8 PTAL

As soon as this is merged, we can cut a new release.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 3, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, rhatdan

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

The pull request process is described here

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

tests/bud.bats Outdated Show resolved Hide resolved
tests/bud.bats Outdated Show resolved Hide resolved
@flouthoc flouthoc force-pushed the buildkit-platform-attemp-2 branch 2 times, most recently from 425572d to 995c7da Compare February 3, 2022 15:00
@flouthoc flouthoc requested a review from vrothberg February 3, 2022 15:02
@test "build-with-inline-platform-amd-but-tag-as-arm" {
# Host arch
run_buildah info --format '{{.host.arch}}'
myarch="$output"
Copy link
Member

Choose a reason for hiding this comment

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

Might be simpler to grep the output of buildah version's BuildPlatform, which provides the entire value you're looking to use.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@nalind I need to toggle only arch at certain places that's why i preferred this. Hope this is not a blocker.

@flouthoc flouthoc force-pushed the buildkit-platform-attemp-2 branch 3 times, most recently from a53b74b to f42b04d Compare February 3, 2022 17:10
@flouthoc flouthoc force-pushed the buildkit-platform-attemp-2 branch from f42b04d to b433cd7 Compare February 3, 2022 17:44
Allows end users to configure executor's `OS`, `ARCH`,`VARIANT` via inline
`--platform`.

Usage
```
FROM --platform=linux/arm64 alpine
RUN uname -a
```
While this allows executor to pull base images with custom
`OS`, `ARCH`, `VARIANT` it still allows end-users to tag images with
different format if they need to.

Signed-off-by: Aditya R <[email protected]>
@flouthoc flouthoc force-pushed the buildkit-platform-attemp-2 branch from b433cd7 to d1a9347 Compare February 3, 2022 18:14
@rhatdan
Copy link
Member

rhatdan commented Feb 3, 2022

/lgtm

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants