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

[build] Cross compile docker images #128272

Merged
merged 15 commits into from
Mar 23, 2022
Merged

Conversation

jbudz
Copy link
Member

@jbudz jbudz commented Mar 22, 2022

This adds a new flag to scripts/build, --docker-cross-compile. This flag will attempt to create docker images for both amd64 and arm64 using docker's buildx environment - https://docs.docker.com/buildx/working-with-bux/.

The primary use case we are trying to support is building ARM64 images from AMD64. We use GCP on CI, and GCP does not support ARM architectures yet.

By default this is off to maintain backwards compatibility with our current build workflow. QEMU needs to be setup on the local environment to support cross compilation, which is outside the scope of our build scripts.

TODO

Testing

apt-get install qemu-user-static

# Verify ARM64 and AMD64 are supported platforms:
docker buildx inspect --bootstrap

yarn build --docker-cross-compile

@jbudz jbudz added Team:Operations Team label for Operations Team backport:skip This commit does not require backporting v8.2.0 ci:build-os-packages labels Mar 22, 2022
@kibana-ci

This comment was marked as outdated.

@jbudz

This comment was marked as resolved.

@jbudz jbudz added v7.17.2 auto-backport Deprecated: Automatically backport this PR after it's merged labels Mar 23, 2022
@jbudz jbudz marked this pull request as ready for review March 23, 2022 15:26
@jbudz jbudz requested a review from a team as a code owner March 23, 2022 15:26
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@jbudz jbudz added the release_note:skip Skip the PR/issue when compiling release notes label Mar 23, 2022
@spalger spalger self-requested a review March 23, 2022 16:41
@spalger spalger added release_note:skip Skip the PR/issue when compiling release notes and removed release_note:skip Skip the PR/issue when compiling release notes labels Mar 23, 2022
Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

Ran the build on a remote-dev instance, loaded the arm64 build and the aarch64 docker image to a graviton instance and they both seemed to work great. LGTM

@jbudz jbudz enabled auto-merge (squash) March 23, 2022 19:19
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@jbudz jbudz merged commit 5b4642b into elastic:main Mar 23, 2022
@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
7.17 Backport failed because of merge conflicts

You might need to backport the following PRs to 7.17:
- [ci] Verify docker contexts (#122897)

Manual backport

To create the backport manually run:

node scripts/backport --pr 128272

Questions ?

Please refer to the Backport tool documentation

@kuisathaverat
Copy link
Contributor

kuisathaverat commented Mar 25, 2022

@spalger @jbudz the change in this PR force to use buildx always even though you do not want to cross compile Docker images other than x86_64

npm install -g yarn
yarn kbn clean
yarn kbn bootstrap --prefer-offline --no-audit --link-duplicates

# build Linux package
node scripts/build

# build docker images
node scripts/build --skip-initialize --skip-generic-folders --skip-platform-folders --skip-archives --docker-images --skip-docker-contexts

cause the following error

[2022-03-24T15:03:34.403Z]    │ info $ ./build_docker.sh
[2022-03-24T15:03:34.974Z]    │ info 20.04: Pulling from library/ubuntu
[2022-03-24T15:03:34.974Z]    │ info Digest: sha256:bea6d19168bbfd6af8d77c2cc3c572114eb5d113e6f422573c93cb605a0e2ffb
[2022-03-24T15:03:34.974Z]    │ info Status: Image is up to date for ubuntu:20.04
[2022-03-24T15:03:34.974Z]    │ info docker.io/library/ubuntu:20.04
[2022-03-24T15:03:34.975Z]    │ info Docker pull successful.
[2022-03-24T15:03:34.975Z]    │ info Building: kibana-cloud-docker
[2022-03-24T15:03:34.975Z]    │ info unknown flag: --platform
[2022-03-24T15:03:34.975Z]    │ info See 'docker --help'.

@jbudz
Copy link
Member Author

jbudz commented Mar 25, 2022

@kuisathaverat I have a fix up at #128560.

@kuisathaverat
Copy link
Contributor

On our end, we have included buildx in our Kibana Docker image builder on Friday

jbudz added a commit to jbudz/kibana that referenced this pull request Apr 1, 2022
* [build] Cross compile docker images

* typo

* debug

* Revert "[build] Cross compile docker images"

This reverts commit 621780e.

* revert

* support docker-cross-compile flag

* fix types/tests

* fix more tests

* download cloud dependencies based on cross compile flag

* fix array

* fix more tests
jbudz added a commit that referenced this pull request Apr 3, 2022
* [7.17] [build] Cross compile docker images (#128272)

* [build] Cross compile docker images

* typo

* debug

* Revert "[build] Cross compile docker images"

This reverts commit 621780e.

* revert

* support docker-cross-compile flag

* fix types/tests

* fix more tests

* download cloud dependencies based on cross compile flag

* fix array

* fix more tests

* rm extra file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated: Automatically backport this PR after it's merged backport:skip This commit does not require backporting backported ci:build-os-packages release_note:skip Skip the PR/issue when compiling release notes Team:Operations Team label for Operations Team v7.17.2 v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants