evilmartians / fullstaq-ruby-docker

Docker image for Ruby build from Fullstaq packages based on Debian 10, 11, and 12.
https://evilmartians.com/chronicles/fullstaq-ruby-first-impressions-and-how-to-migrate-your-docker-kubernetes-ruby-apps-today
174 stars 21 forks source link

failed to install nokogiri #7

Closed kingpalethe closed 4 years ago

kingpalethe commented 4 years ago

This project looks great!

I am trying to use the dockerfile... but currently failing in bundle install when it gets to nokogiri

Installing nokogiri 1.10.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/usr/local/bundle/ruby/2.7.0/gems/nokogiri-1.10.10/ext/nokogiri
/usr/lib/fullstaq-ruby/versions/2.7.1-jemalloc/bin/ruby -I
/usr/lib/fullstaq-ruby/versions/2.7.1-jemalloc/lib/ruby/2.7.0 -r
./siteconf20200812-1-1kfq7iw.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.4.0
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.10
with the following patches applied:
        - 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch
        - 0002-Remove-script-macro-support.patch
        - 0003-Update-entities-to-remove-handling-of-ssi.patch
        - 0004-libxml2.la-is-in-top_builddir.patch
        - 0005-Fix-infinite-loop-in-xmlStringLenDecodeEntities.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.10.tar.gz into
tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.10... OK
*** 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/lib/fullstaq-ruby/versions/2.7.1-jemalloc/bin/$(RUBY_BASE_NAME)
        --help
        --clean
        --use-system-libraries
        --enable-static
        --disable-static
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/lib
        --enable-cross-build
        --disable-cross-build
/usr/local/bundle/ruby/2.7.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:84:in
`apply_patch': Failed to complete patch task; patch(1) or git(1) is required.
(RuntimeError)
from
/usr/local/bundle/ruby/2.7.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:92:in
`block in patch'
from
/usr/local/bundle/ruby/2.7.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:90:in
`each'
from
/usr/local/bundle/ruby/2.7.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:90:in
`patch'
from
/usr/local/bundle/ruby/2.7.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:152:in
`cook'
        from extconf.rb:365:in `block (2 levels) in process_recipe'
        from extconf.rb:257:in `block in chdir_for_build'
        from extconf.rb:256:in `chdir'
        from extconf.rb:256:in `chdir_for_build'
        from extconf.rb:364:in `block in process_recipe'
        from extconf.rb:262:in `tap'
        from extconf.rb:262:in `process_recipe'
        from extconf.rb:557:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

/usr/local/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/nokogiri-1.10.10/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/usr/local/bundle/ruby/2.7.0/gems/nokogiri-1.10.10 for inspection.
Results logged to
/usr/local/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/nokogiri-1.10.10/gem_make.out

An error occurred while installing nokogiri (1.10.10), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.10.10' --source
'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  rails was resolved to 6.0.3.2, which depends on
    actioncable was resolved to 6.0.3.2, which depends on
      actionpack was resolved to 6.0.3.2, which depends on
        actionview was resolved to 6.0.3.2, which depends on
          rails-dom-testing was resolved to 2.0.3, which depends on
            nokogiri
ERROR: Service 'web' failed to build: The command '/bin/bash -o pipefail -c bundle install #--jobs 4' returned a non-zero code: 5

here is the DockerFile

ARG RUBY_VERSION=2.7.1-jemalloc
FROM quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-slim

LABEL project="voxserver"

RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
    apt-transport-https \
    gnupg2

RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
    apt-get update -yqq && apt-get install -yqq --no-install-recommends \
    nodejs \
    postgresql-client \
    ffmpeg \ 
    sox

RUN apt-get install libsox-fmt-mp3 -y

# RUN gem install foreman

RUN apt-get install libimlib2 libimlib2-dev -y

COPY Gemfile* /usr/src/app/ 
WORKDIR /usr/src/app
RUN bundle install #--jobs 4

#
COPY . /usr/src/app/

RUN echo 'PS1="\[$(tput setaf 3)$(tput bold)[\]voxserver:\\w]#\[$(tput sgr0) \]"' >> /root/.bashrc
# RUN echo 'fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p'   #setting this in parent machine!!

COPY delete_pid.sh /usr/bin/
RUN chmod +x /usr/bin/delete_pid.sh
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install yarn
RUN yarn install --check-files
Envek commented 4 years ago

Here is the essence of your error:

Failed to complete patch task; patch(1) or git(1) is required.

Reason is that slim image is really slim :smiley:

Try to install git and build-essential packages (it is good to have git installed if you have some gems in your Gemfile not from rubygems, but from git)

kingpalethe commented 4 years ago

Thanks, to get nokogiri and pg gems to install, I had to add this to the top of my Dockerfile

RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
    apt-transport-https \
    gnupg2 \ 
    curl \
    build-essential \
    patch \
    git \
    zlib1g-dev \
    liblzma-dev \
    libpq-dev