Reputation: 124
I have a web project running with the php7-fpm image. For this project, I need to install the Ruby gem sass.
But on building the container with, it fails saying it lacks some headers from the libffi-dev package. Package I've added in my package installations at the beginning of my Dockerfile.
Does anyone has any idea what I could do to fix this?
Here goes my Dockerfile :
FROM phpdockerio/php7-fpm:latest
# Install selected extensions
RUN apt-get update \
&& apt-get -y --no-install-recommends install php7.0-memcached php7.0-mysql php7.0-redis php7.0-gd php7.0-imagick php7.0-intl php7.0-xdebug php7.0-mbstring \
&& apt-get -y --no-install-recommends install nodejs npm nodejs-legacy vim ruby-full git libffi-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN npm install -g bower
RUN npm install -g less
RUN gem install sass
# If you're using symfony and the vagranted environment, I strongly recommend you change your AppKernel to use the following temporary folders
# for cache, logs and sessions, otherwise application performance may suffer due to these being shared over NFS back to the host
RUN mkdir -p "/tmp/elinoi/cache" \
&& mkdir -p "/tmp/elinoi/logs" \
&& mkdir -p "/tmp/elinoi/sessions" \
&& chown www-data:www-data -R "/tmp/elinoi"
RUN apt-get update \
&& apt-get -y --no-install-recommends install openssh-server \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN mkdir /var/run/sshd
RUN echo 'root:screencast' | chpasswd
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
EXPOSE 22
ADD docker/.ssh /root/.ssh
RUN chmod 700 /root/.ssh/authorized_keys
CMD ["/usr/sbin/sshd", "-D"]
WORKDIR "/var/www/elinoi.com"
And the error given:
Step 5/19 : RUN gem install ffi --version="1.9.18"
---> Running in 35fc010838c3
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/ffi-1.9.18/ext/ffi_c
/usr/bin/ruby2.3 -r ./siteconf20180307-7-472r8y.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
--with-ffi_c-dir
--without-ffi_c-dir
--with-ffi_c-include
--without-ffi_c-include=${ffi_c-dir}/include
--with-ffi_c-lib
--without-ffi_c-lib=${ffi_c-dir}/lib
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/usr/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/lib/ruby/2.3.0/mkmf.rb:587:in `try_cpp'
from /usr/lib/ruby/2.3.0/mkmf.rb:1091:in `block in have_header'
from /usr/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /usr/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
from /usr/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
from /usr/lib/ruby/2.3.0/mkmf.rb:1090:in `have_header'
from extconf.rb:16:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.18/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/ffi-1.9.18 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.18/gem_make.out
ERROR: Service 'elinoi-php-fpm' failed to build: The command '/bin/sh -c gem install ffi --version="1.9.18"' returned a non-zero code: 1
Upvotes: 0
Views: 4561
Reputation: 13260
Your image is missing the gcc/g++ compiler and therefore it can't build any native code, as you can clearly see from the error message:
You have to install development tools first.
You can install the build-essential
metapackage to get a working build environment inside your image.
RUN apt-get install -y build-essential
Of course you need the above line before the gem install RUN command you already have
Upvotes: 2