jruby / docker-jruby

MIT License
18 stars 27 forks source link

Include GNU make in docker images to avoid issues while installing native gems #82

Closed ivoanjo closed 1 year ago

ivoanjo commented 1 year ago

What does this PR do?:

This PR adds GNU make to the apt-get install set of all Dockerfiles.

Motivation:

As discussed in #81, several gems (ddtrace, bootsnap, stackprof, gvltools) autodetect in their extconf.rb if they're running on JRuby, and avoid attempting to compile their native extension in that case.

Unfortunately, the "avoid attempting to compile" is implemented by writing a dummy almost-empty Makefile, which rubygems still tries to run. This breaks if GNU make is not installed.

GNU make is quite small, so this seems a nice improvement in user experience for users of the JRuby docker images.

How to test the change?:

Before:

$ gem install bootsnap
Fetching bootsnap-1.14.0.gem
Fetching msgpack-1.6.0-java.gem
Successfully installed msgpack-1.6.0-java
Building native extensions. This could take a while...
ERROR:  Error installing bootsnap:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/bootsnap-1.14.0/ext/bootsnap
/opt/jruby/bin/jruby -I /opt/jruby/lib/ruby/stdlib -r ./siteconf20221121-34-we57cb.rb extconf.rb

current directory: /usr/local/bundle/gems/bootsnap-1.14.0/ext/bootsnap
make DESTDIR\= clean
sh: 1: exec: make: not found

current directory: /usr/local/bundle/gems/bootsnap-1.14.0/ext/bootsnap
make DESTDIR\=
sh: 1: exec: make: not found

make failed, exit code 127

Gem files will remain installed in /usr/local/bundle/gems/bootsnap-1.14.0 for inspection.
Results logged to /usr/local/bundle/extensions/universal-java-17/2.6.0/bootsnap-1.14.0/gem_make.out

After:

$ gem install bootsnap
Fetching msgpack-1.6.0-java.gem
Fetching bootsnap-1.14.0.gem
Successfully installed msgpack-1.6.0-java
Building native extensions. This could take a while...
Successfully installed bootsnap-1.14.0
2 gems installed

Fixes #81

ivoanjo commented 1 year ago

Update: Rebased PR and added makefile to the newly-added 9.4 Dockerfiles as well. Congrats on the 9.4 release, btw!

headius commented 1 year ago

Yup good, I missed this before the holidays but I'll merge now and update Hub!