Gem therubyracer 未安装在 alpine docker 容器中

时间:2021-03-16 09:38:14

标签: ruby linux docker rubygems alpine

我正在尝试使用基本的 alpine docker 映像 (alpine:3.11) 使用 ruby​​ 构建一个 docker 容器。

并且我已经安装了最常见的存储库: build-deps build-base make python git bash gmp-dev zlib-dev libressl-dev gdbm-dev db-dev readline-dev libffi-dev coreutils yaml-dev linux-headers autoconf

此外,使用以下命令安装 libv8 gem:

gem install libv8 -v '3.16.14.16' -- --with-system-v8

然后当我尝试使用以下命令安装 therubyracer 时:

gem install therubyracer -v '0.12.3'

它给了我很长的错误信息:

ERROR:  Error installing therubyracer:

current directory: /usr/lib/ruby/gems/2.6.0/gems/therubyracer-0.12.3/ext/v8                                                                                                                            
/usr/bin/ruby -I /usr/lib/ruby/2.6.0 -r ./siteconf20210316-1-1t6t8wp.rb extconf.rb --with-v8-dir\=/usr/lib/ruby/gems/2.6.0/gems/therubyracer-0.12.3/                                                       
checking for -lpthread... yes                                                                                                                                                                              
checking for v8.h... no
*** 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)
        --with-pthreadlib
        --without-pthreadlib
        --enable-debug
        --disable-debug
        --with-v8-dir
        --with-v8-include
        --without-v8-include=${v8-dir}/include
        --with-v8-lib
        --without-v8-lib=${v8-dir}/lib /usr/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.16/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version  (Libv8::Location::System::NotFoundError)of V8 found on your system and *not* the one that is bundled with the libv8 rubygem. However, your system version of v8 could not be located. Please make sure your system version of v8 that is compatible with 3.16.14.16 installed. You may need to use the --with-v8-dir option if it is installed in a non-standard location         from /usr/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.16/lib/libv8.rb:7:in `configure_makefile' from extconf.rb:32:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /usr/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/therubyracer-0.12.3/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /usr/lib/ruby/gems/2.6.0/gems/therubyracer-0.12.3 for inspection. Results logged to /usr/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/therubyracer-0.12.3/gem_make.out The command '/bin/sh -c gem install therubyracer -- --with-v8 dir=/usr/lib/ruby/gems/2.6.0/gems/therubyracer-0.12.3/' returned a non-zero code: 1

这是我的 dockerfile:-

FROM alpine:3.11
ENV BUILD_PACKAGES="curl-dev ruby-dev build-base" \
    DEV_PACKAGES="zlib-dev libxml2-dev libxslt-dev tzdata yaml-dev sqlite-dev postgresql-dev mysql-dev" \
    RUBY_PACKAGES="ruby ruby-io-console ruby-json yaml nodejs" \
    RAILS_VERSION="4.2.3"

RUN apk --update --upgrade add $BUILD_PACKAGES $RUBY_PACKAGES $DEV_PACKAGES
RUN apk --no-cache add gmp-dev libressl-dev gdbm-dev db-dev readline-dev libffi-dev coreutils yaml-dev linux-headers autoconf
RUN apk add --update --no-cache --virtual build-deps make python2 git bash libstdc++
RUN apk add alpine-sdk findutils binutils-gold yarn npm postgresql postgresql-client curl
  
RUN gem install -N nokogiri -- --use-system-libraries && \
  gem install -N rails --version "$RAILS_VERSION" && \
  echo 'gem: --no-document' >> ~/.gemrc && \
  cp ~/.gemrc /etc/gemrc && \
  chmod uog+r /etc/gemrc && \
  # cleanup and settings
  bundle config --global build.nokogiri  "--use-system-libraries" && \
  bundle config --global build.nokogumbo "--use-system-libraries" && \
  find / -type f -iname \*.apk-new -delete && \
  rm -rf /var/cache/apk/* && \
  rm -rf /usr/lib/lib/ruby/gems/*/cache/* && \
  rm -rf ~/.gem
RUN gem install bundler -v '1.17.3'
RUN gem install libv8 -v '3.16.14.16' -- --with-system-v8
RUN gem install therubyracer -v '0.12.3'
RUN mkdir /usr/app
WORKDIR /usr/app
COPY Gemfile /usr/app/
RUN bundle install
EXPOSE 3000

0 个答案:

没有答案