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

docker-compose.yml does not work on m1 macs #4369

Closed
Christewart opened this issue Jun 5, 2022 · 8 comments
Closed

docker-compose.yml does not work on m1 macs #4369

Christewart opened this issue Jun 5, 2022 · 8 comments

Comments

@Christewart
Copy link
Contributor

Christewart commented Jun 5, 2022

Tested on 0a0fc92

Here is the corresponding docker image

https://hub.docker.com/layers/227603796/bitcoinscala/bitcoin-s-server/1.9.1-75-0a0fc92f-SNAPSHOT/images/sha256-60861248ea4c099877fa04fee732332e4e6640d1ef7de57cdf79d4a9d042eda9?context=repo

The image constantly says "No java detected"

Screen Shot 2022-06-05 at 1 23 59 PM

My am64 linux machine works fine on the same docker image.

@Christewart Christewart added this to the 1.9.2 milestone Jun 5, 2022
@Christewart Christewart added this to TODO in 1.9.2 via automation Jun 5, 2022
@Christewart
Copy link
Contributor Author

Christewart commented Jun 6, 2022

So ran an image to get access to the filesystem on the container, and attempted to run ./jre/bin/java -version to see if java can run and ran into this error:

Screen Shot 2022-06-06 at 11 04 37 AM

From a quick google, this means the jre is incompatible with the underlying chip architecture.

https://mkyong.com/java/bash-usr-bin-java-cannot-execute-binary-file-exec-format-error/

I don't really understand how this can be the case though as I built this image locally on my m1 mac and am attempting to run it locally on m1 mac. jlink should be fetching from a aarch64 jre.

For remotely built images, this is likely an issue as I'm guessing CI machines are x86, which means the jre built by jlink would also be x86.

bitcoin-s@d672864e1b18:/opt/docker$ ./jre/bin/java
bash: ./jre/bin/java: cannot execute binary file: Exec format error

@Christewart
Copy link
Contributor Author

@Christewart
Copy link
Contributor Author

This seems to be the root cause, the runtime linker used by jlink is not available in the docker image. The suggested workaround is to containerize the build process so that there is not differences between the build machine and the docker image

https://stackoverflow.com/a/63595415/967713

@Christewart
Copy link
Contributor Author

Christewart commented Jun 8, 2022

So the problem seems to be that the jre is expecting the linker /lib64/ld-linux-x86-64.so.2 to be available to it. Since this is not available, the java runtime fails immediately

Screen Shot 2022-06-08 at 8 52 21 AM

Screen Shot 2022-06-08 at 8 53 59 AM

On x86 machine this linker does exist which is why java starts

Screenshot from 2022-06-08 08-54-36

@Christewart
Copy link
Contributor Author

Christewart commented Jun 8, 2022

Unfortunately it seems that linux/arm64 runners are not likely to come to github actions anytime soon: actions/runner-images#2536

It also doesn't look like native m1 support will be added to github actions anytime soon:

actions/runner-images#2187

@Christewart
Copy link
Contributor Author

Christewart commented Jun 8, 2022

Summary

Building jre with jlink outside of the docker image and copying it inside

This fails because the jre is now built with x86 specific linkage. When we go to run java it fails because it cannot find the x86 linker. See this comment

Containerizing building the jre inside of both arm64/x86 docker containers

This cannot work on github actions because MS does not allow arm64 runners on github actions. This means we cannot natively run the arm64 build container on to properly build the arm64 docker runtime.

Path forward

I think the only path forward is to build with openjdk (essentially revert #4367) docker images and disable the jlink plugin somehow on docker builds.

Unfortunately this also means our normal zip build for m1 macs will have the same problem. We will have to ask the user to install java if they are using an m1 mac.

@Christewart
Copy link
Contributor Author

Documentation on how to self host github runners: https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners

@Christewart
Copy link
Contributor Author

Docker portion is fixed, native m1 mac is now tracked by this issue: #4383

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
1.9.2
Done
Development

No branches or pull requests

1 participant