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

Error when trying to build an image for ruby 2.5.9 with an arm64 arch #32

Open
alexandrebryszkowski opened this issue Apr 7, 2022 · 3 comments

Comments

@alexandrebryszkowski
Copy link

Hello,

I've got a problem when trying to build an image for ruby 2.5.9 with an arm64 arch with the focal version of Ubuntu.

I need a docker image for ruby 2.5.9 with a arm64 architecture working on a M1 processor from Apple (on macOS 12.1), but I've got this error:

rake --trace docker:build arch=arm64 ruby_version=2.5.9 ubuntu_version=focal
** Invoke docker:build (first_time)
** Execute docker:build
docker run --rm --privileged multiarch/qemu-user-static:register --reset
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
standard_init_linux.go:228: exec user process caused: exec format error
rake aborted!
Command failed with status (1): [docker run --rm --privileged multiarch/qem...]
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/file_utils.rb:67:in `block in create_shell_runner'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/file_utils.rb:57:in `sh'
/Users/alex/git/ruby-docker-images/Rakefile:133:in `block (2 levels) in <top (required)>'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/bin/rake:23:in `load'
/usr/bin/rake:23:in `<main>'
Tasks: TOP => docker:build

Am I missing something ?

Thank you

@plus-
Copy link

plus- commented Apr 11, 2022

Try and comment this line: https://github.com/ruby/ruby-docker-images/blob/master/Rakefile#L133

I believe it's to run docker through qemu as arm64 when your cpu is not an M1, and since you are using M1 you don't need that.

@alexandrebryszkowski
Copy link
Author

Hello,

Thank you for your response.
It works but it seems bundle was not present:

#11 63.63 + ruby --version
#11 63.63 ruby 2.5.9p229 (2021-04-05 revision 67939) [aarch64-linux]
#11 63.63 + gem --version
#11 63.68 2.7.6.3
#11 63.68 + bundle --version
#11 63.68 /tmp/install_ruby.sh: line 94: bundle: command not found
------
executor failed running [/bin/sh -c set -ex &&     mkdir -p /usr/local/etc &&     {       echo 'install: --no-document';       echo 'update: --no-document';     } >> /usr/local/etc/gemrc &&         /tmp/install_ruby.sh &&     rm /tmp/install_ruby.sh &&         dpkg-query --show --showformat '${package}\n'       | grep -P '^libreadline\d+$'       | xargs apt-mark manual &&         apt-get purge -y --auto-remove $(cat /tmp/ruby_build_deps.txt) &&     rm /tmp/ruby_build_deps.txt]: exit code: 127
rake aborted!
Command failed with status (1): [docker build -f Dockerfile-arm64 -t rubyla...]
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/file_utils.rb:67:in `block in create_shell_runner'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/file_utils.rb:57:in `sh'
/Users/alex/git/ruby-docker-images/Rakefile:134:in `block (2 levels) in <top (required)>'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
/Users/alex/.gem/ruby/2.6.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/bin/rake:23:in `load'
/usr/bin/rake:23:in `<main>'
Tasks: TOP => docker:build

So I commented 'bundle --version' here : https://github.com/ruby/ruby-docker-images/blob/master/install_ruby.sh#L94

And now it works :

rake --trace docker:build arch=arm64 ruby_version=2.5.9 ubuntu_version=focal
** Invoke docker:build (first_time)
** Execute docker:build
docker build -f Dockerfile-arm64 -t rubylang/ruby:2.5-arm64 -t rubylang/ruby:2.5-focal-arm64 -t rubylang/ruby:2.5.9-focal-arm64 --build-arg cppflags= --build-arg optflags= --build-arg RUBY_VERSION=2.5.9 --build-arg BASE_IMAGE_TAG=focal .
[+] Building 65.8s (12/12) FINISHED
 => [internal] load build definition from Dockerfile-arm64                                                                                 0.0s
 => => transferring dockerfile: 90B                                                                                                        0.0s
 => [internal] load .dockerignore                                                                                                          0.0s
 => => transferring context: 2B                                                                                                            0.0s
 => [internal] load metadata for docker.io/multiarch/ubuntu-core:arm64-bionic                                                              1.1s
 => [1/7] FROM docker.io/multiarch/ubuntu-core:arm64-bionic@sha256:6c0f156593134d7569dd76e4b59c8165c21df68e057f0082fded28ebd51eb214        0.0s
 => [internal] load build context                                                                                                          0.0s
 => => transferring context: 2.62kB                                                                                                        0.0s
 => CACHED [2/7] ADD ruby_build_deps.txt /tmp/                                                                                             0.0s
 => CACHED [3/7] RUN set -ex &&         apt-get update &&     apt-get install -y --no-install-recommends             ca-certificates       0.0s
 => CACHED [4/7] RUN set -ex &&     useradd -ms /bin/bash ubuntu                                                                           0.0s
 => CACHED [5/7] ADD tmp/ruby /usr/src/ruby                                                                                                0.0s
 => [6/7] ADD install_ruby.sh /tmp/                                                                                                        0.0s
 => [7/7] RUN set -ex &&     mkdir -p /usr/local/etc &&     {       echo 'install: --no-document';       echo 'update: --no-document';    63.8s
 => exporting to image                                                                                                                     0.7s
 => => exporting layers                                                                                                                    0.7s
 => => writing image sha256:e9dd05e395b63190f04844c6616898549eaf2ec9eb85a3525dc01992437a3d8f                                               0.0s
 => => naming to docker.io/rubylang/ruby:2.5-arm64                                                                                         0.0s
 => => naming to docker.io/rubylang/ruby:2.5-focal-arm64                                                                                   0.0s
 => => naming to docker.io/rubylang/ruby:2.5.9-focal-arm64                                                                                 0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

Thank you for your help!

@zedtux
Copy link

zedtux commented Jul 18, 2022

For anyone reading this, Bundler is part of Ruby since version 2.6 while we are trying to build the image for Ruby 2.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants