我的Doc Dockerfile来自FROM Ubuntu:18.04
我想用红宝石,所以我做了
gem install bundler
但是,当我尝试
bundle
我收到nokogiri错误
Installing nokogiri 1.10.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.5.0/gems/nokogiri-1.10.2/ext/nokogiri
/usr/bin/ruby2.5 -r ./siteconf20190414-288-1mfprtc.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.5.0/gems/nokogiri-1.10.2 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.10.2/gem_make.out
An error occurred while installing nokogiri (1.10.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.10.2' --source 'http://rubygems.org/'` succeeds before bundling.
答案 0 :(得分:1)
您有一个名为nokogiri
的依赖关系,它具有外部依赖关系,通常是libxml和libxslt。
您需要做的只是apt get install libxml2-dev libxslt1-dev
这是Ruby Dockerfile
FROM ruby:2.6.2
RUN apt-get update -qq && apt-get install -y build-essential
RUN apt-get install -y libxml2-dev libxslt1-dev
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY Gemfile* /usr/src/app/
RUN bundle install -j3
ADD . /usr/src/app
ENTRYPOINT ["bundle", "exec"]
CMD ["rails", "server"]