I'm trying to build a Docker image based on ruby:3.0. Inside Dockerfile, when running "RUN bundle install", start installing dependencies until error is shown:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension. #10 34.20 #10 34.20 current directory: /usr/local/bundle/gems/tiny_tds-2.1.5/ext/tiny_tds #10 34.20 /usr/local/bin/ruby -I /usr/local/lib/ruby/3.0.0 -r #10 34.20 ./siteconf20220804-7-s3hvms.rb extconf.rb #10 34.20 looking for freetds headers in the following directories: #10 34.20 - /opt/local/include #10 34.20 - /opt/local/include/freetds #10 34.20 - /usr/local/include #10 34.20 - /usr/local/include/freetds #10 34.20 looking for freetds library in the following directories: #10 34.20 - /opt/local/lib #10 34.20 - /opt/local/lib/freetds #10 34.20 - /usr/local/lib #10 34.20 - /usr/local/lib/freetds
Normally this issue is solved installing linux distribution headers files that is using, but in this case, I am not know how do it.
Dockerfile is this:
FROM ruby:3.0
## throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
WORKDIR /usr/src/app
COPY Gemfile Gemfile.lock ./
RUN gem i bundler
RUN bundle install
COPY . .
CMD ["rails c"]
I tried adding this to Dockerfile, but another error was shown:
RUN apt-get install ruby-dev
Thank you very much in advance to whoever can help me.
CodePudding user response:
Try building on the 3.0-buster image because I think that comes with additional packages. More info here: https://hub.docker.com/_/ruby
CodePudding user response:
I run RUN apt-get install ruby-dev
in Dockerfile and this issue is the same to you.
I change to bellow. Beside you can add other lib such as nodejs
postgresql-client
... I have consulted here https://docs.docker.com/samples/rails/
RUN apt-get update -qq && apt-get install -yq --no-install-recommends \
libpq-dev \
ruby-dev
or
RUN apt-get update -qq && apt-get install -y ruby-dev