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

WIP: feat: build the docker image for amd64 and arm64 platforms #7512

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Dzejkop
Copy link

@Dzejkop Dzejkop commented Mar 28, 2024

Motivation

Closes #8039
Using the docker image (ghcr.io/foundry-rs/foundry) on an Apple Silicon machine runs with the following warning:

 The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

and is likely suffering slowdowns due to emulation.

Solution

This PR should build the images for both amd64 and arm64 platforms

@Dzejkop Dzejkop changed the title Build the docker image for amd64 and arm64 platforms. feat: build the docker image for amd64 and arm64 platforms Mar 28, 2024
@Dzejkop Dzejkop changed the title feat: build the docker image for amd64 and arm64 platforms WIP: feat: build the docker image for amd64 and arm64 platforms Mar 28, 2024
@Dzejkop
Copy link
Author

Dzejkop commented Mar 28, 2024

I'm still waiting for the workflow to pass on my repo https://github.com/Dzejkop/foundry/actions/runs/8467842044/job/23199474123

@DaniPopes DaniPopes requested a review from onbjerg March 29, 2024 04:14
@onbjerg onbjerg marked this pull request as draft March 29, 2024 08:49
@onbjerg
Copy link
Member

onbjerg commented Mar 29, 2024

Marking this as a draft, please move it out of draft once you are ready for reviews :)

@vladislavabramov
Copy link

good lord i need this, the emulation slowdowns have been giving us so much headache lately 😅

@Sn0rt
Copy link

Sn0rt commented May 7, 2024

any update for this PR ?

@onbjerg I have try this PR undery my fork.

I found that I can't move this feature forward. because the release CI need specified runner.

more detail: https://github.com/Sn0rt/foundry/actions/runs/8999845047/job/24722880500

@peterZhang000
Copy link

When will the package succeed, my local package has been compiling for 2 hours now and it's not coming out!

@onbjerg
Copy link
Member

onbjerg commented May 9, 2024

@Sn0rt no update, OP has not circled back

@grandizzy
Copy link
Collaborator

grandizzy commented Jun 8, 2024

unfortunately this approach doubles time of building, as there's a single runner building for both platforms, we'd need something like https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners to parallelize them

this can be tested locally by installing a registry on localhost:5000 and run the job using act (https://github.com/nektos/act)

docker run -d -p 5000:5000 --restart always --name registry registry:2
act --job release-docker

@Thegaram
Copy link

unfortunately this approach doubles time of building

Is that an issue in practice?

@grandizzy
Copy link
Collaborator

unfortunately this approach doubles time of building

Is that an issue in practice?

I think so, pretty sure this will kick in

timeout-minutes: 120
(at least on my local machine took more than 2 hours)

@Thegaram
Copy link

I tried building locally like this:

docker build -t foundry-arm64 . --platform linux/arm64

It seemed to work well at first but running forge build in this image failed with (see extensive discussion in the telegram group):

"/root/.svm/0.8.24/solc-0.8.24": No such file or directory (os error 2)

It seems that simply building an image for arm64 might not always work as expected.

@stleon
Copy link

stleon commented Jun 19, 2024

Hi @Thegaram ,
thank you for share your Dockerfile in telegram channel :)

In my case adding

RUN forge install foundry-rs/forge-std --no-commit --no-git

before RUN forge build resolves the problem

@sambacha
Copy link
Contributor

A better way to do this would be to define a docker.hcl file like so:

# -*- hcl -*-

/** Special target: https://github.com/docker/metadata-action#bake-definition */
// docker-bake.hcl
target "docker-metadata-action" {}

target "build" {
  inherits = ["docker-metadata-action"]
  context = "./"
  dockerfile = "Dockerfile"
  platforms = [
    "linux/amd64",
    "linux/arm64"
  ]

But really, this begs the question: why even compile for docker? Why not just use the built artifacts and just package it after the fact vs. compiling for docker to begin with?

@grandizzy
Copy link
Collaborator

But really, this begs the question: why even compile for docker? Why not just use the built artifacts and just package it after the fact vs. compiling for docker to begin with?

That makes sense IMO

@olivmath
Copy link

Comment here to be notified when it's ready

@Dzejkop
Copy link
Author

Dzejkop commented Jul 2, 2024

Sorry guys, didn't have the time to follow through with this.

But really, this begs the question: why even compile for docker? Why not just use the built artifacts and just package it after the fact vs. compiling for docker to begin with?

it's a little nicer in terms of workflow. I can just run docker build no matter the host platform (to a reasonable degree) instead of worrying about deps for the cross compilation tooling.

AFAIR the compilation time is really bad in case of arm host and x86 guest but the other way around shouldn't be so bad.

I should be able to allocate some time for this this week

@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 31, 2024
@zerosnacks zerosnacks added the A-releases Area: releases/packaging label Jul 31, 2024
@publicqi
Copy link

publicqi commented Sep 1, 2024

Do we have an update on this? Can we just use mac runner to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-releases Area: releases/packaging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apple Silicon (M1/M2) - no matching manifest for linux/arm64/v8 error with ghcr.io/foundry-rs/foundry:latest