Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Update build scripts to use "docker buildx build" #914

Closed
Chuxel opened this issue Jun 24, 2021 · 9 comments
Closed

Update build scripts to use "docker buildx build" #914

Chuxel opened this issue Jun 24, 2021 · 9 comments
Assignees
Labels
build-system feature-request Request for new features or functionality

Comments

@Chuxel
Copy link
Member

Chuxel commented Jun 24, 2021

As a part of the work to enable ARM64 for images, we'll need to switch the build system to use buildx instead of the default docker build. e.g.

docker buildx create --use --name multiarch
docker run --privileged --rm tonistiigi/binfmt --install all
docker buildx build .devcontainer -f .devcontainer/base.Dockerfile --platform linux/amd64,linux/arm64
@Chuxel Chuxel self-assigned this Jun 24, 2021
@Chuxel Chuxel added build-system feature-request Request for new features or functionality labels Jun 24, 2021
@Chuxel
Copy link
Member Author

Chuxel commented Jul 12, 2021

The branch https://github.com/microsoft/vscode-dev-containers/tree/clantz/mutli-arch-build has a working version of the build, but buildx is reporting a native crash in a simple curl call (likely tied to something QEMU and openSSL) when trying to execute the build in GitHub Actions or emulated. This is blocking merge.

@imakahn
Copy link

imakahn commented Jul 16, 2021

Hi @Chuxel

I was working through the node-debian.sh script and also experienced the segfault on the curl call to fetch the yarn gpg file. The issue has been detailed here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=989604

A immediate workaround would be to use wget, as such:

wget https://dl.yarnpkg.com/debian/pubkey.gpg -O /tmp/pubkey.gpg
cat /tmp/pubkey.gpg | gpg --dearmor > /usr/share/keyrings/yarn-archive-keyring.gpg

However this would still leave the global curl being shipped as broken for some https urls.

So to instead resolve that (and leave the curl call unchanged):

wget https://cloudfront.debian.net/debian/pool/main/o/openssl/libssl1.1_1.1.1k-1_arm64.deb -O /tmp/libssl1.1_1.1.1k-1_arm64.deb
sudo dpkg -i /tmp/libssl1.1_1.1.1k-1_arm64.deb

I hope this helps!

@Chuxel
Copy link
Member Author

Chuxel commented Jul 16, 2021

@imakahn Thanks for the tip! Yeah, beyond curl, its libssl itself that is broken, so I saw a number of issues. This one was just the really obvious one. I'm a bit wary to bring in testing bits into stable. I'd expect this will get pulled into stable (soon to be old-stable), but there's a lot of focus on bullseye right now.

@Dids
Copy link

Dids commented Aug 19, 2021

Have there been any updates with this?

So far I've been creating my own images/forks of the definitions available in this repo, as well as replacing all curl calls with wget, to get rid of the QEMU crashes when doing multi-arch builds.

While this has worked fine, it's rather cumbersome to have to maintain forks/custom images, so I'd very much love to see this implemented as soon as possible, as well as platform selection in build scripts for images that have been tested against multiple architectures.

I'm definitely open and happy to help with this any way I can, as devcontainers are an extremely powerful tool for my workflows, as well as my client's.


On a likely unrelated note, when I was testing and building ARM64 images on my M1 MBP running macOS Monterey, I noticed that port 80 was being blocked for inbound traffic, which only happens on this device/OS configuration. macOS Monterey does include multiple networl related changes, but this particular issue isn't mentioned anywhere, at least that I could find.
This caused all apt repositories to fail to connect, which I could reproduce locally in all 3rd party browsers, except in Safari, which works as expected.
Simply switching all apt repositories from HTTP to HTTPS was enough to fix this, and I've yet to confirm from any official sources of macOS Monterey is the culprit here, but as of right now it seems plausible.

@Chuxel
Copy link
Member Author

Chuxel commented Aug 19, 2021

As mentioned in the other thread, things like SDKMAN are affected as well, so just switching to wget doesn't resolve the problem.

@Chuxel
Copy link
Member Author

Chuxel commented Aug 31, 2021

This part has been merged. Additional tracking of images using it will be tracked under #558.

@Chuxel Chuxel closed this as completed Aug 31, 2021
@bourquep
Copy link

bourquep commented Feb 8, 2022

@Chuxel I have a Dockerfile-based devcontainer, whose FROM image is multi-arch and which can build properly with buildx.

But when I "build and open in devcontainer", the image is built for amd64 only, not multiarch. How can I tell vscode to use buildx --platform ...?

@eitsupi
Copy link
Contributor

eitsupi commented Feb 8, 2022

@bourquep I recommend reading the buildx documentation. It is not possible to load multiplatform images into local Docker.

https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#load

The docker export type writes the single-platform result image as a Docker image specification tarball on the client.

@Chuxel
Copy link
Member Author

Chuxel commented Feb 8, 2022

@bourquep Docker will use your local architecture by default unless the upstream image does not support arm64.

If you want to force emulation, you can set the DOCKER_DEFAULT_PLATFORM environment variable when starting VS Code.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
build-system feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

5 participants