Bundle install on Docker Container takes forever

My rails 5 build for the past day started to run slow inside the docker build. This only happens on TravisCI.

Here are the steps:

  • Install latest Ruby with RVM
  • Update gem and install bundler
  • Bundle install (takes less than a minute)
  • Run the tests
  • If they pass, build the docker image to send to AWS
  • Docker image tries to bundle install (takes 15 minutes or so)

I keep seeing this message when the bundle install is running inside the container:

Retrying download gem from https://rubygems.org/ due to error (2/4): Gem::RemoteFetcher::UnknownHostError timed out (https://rubygems.org/gems/crass-1.0.4.gem)

Here’s my .travis.yml file:

sudo: required
language: ruby
rvm: 2.6.3

services:
  - postgresql
  - docker

branches:
  only:
    - master

before_install:
  - sudo /etc/init.d/postgresql stop
  - sudo apt-get install postgresql-contrib-9.6
  - gem update --system
  - gem install bundler

before_script:
  - RAILS_ENV=test bundle exec rake db:create
  - RAILS_ENV=test bundle exec rake db:migrate

script:
  - bundle exec rspec

after_success:
  - pip install --user awscli
  - export PATH=$PATH:/$HOME/.local/bin
  - aws ecr create-repository --repository-name $REPO --region $AWS_REGION
  - eval $(aws ecr get-login --region $AWS_REGION --no-include-email)
  - docker build -t $REPO .
  - docker tag $REPO:latest $AWS_ACCOUNT_NUMBER.dkr.ecr.$AWS_REGION.amazonaws.com/$REPO:latest
  - docker push $AWS_ACCOUNT_NUMBER.dkr.ecr.$AWS_REGION.amazonaws.com/$REPO:latest

And here is my Dockerfile:

FROM ruby:2.6.3-alpine3.9

# Install required libraries and dependencies
RUN apk add --update --no-cache \
      build-base \
      git \
      xz \
      tzdata \
      gcc \
      libxml2-dev \
      libxslt-dev \
      imagemagick \
      bash \
      ca-certificates \
      postgresql-dev

RUN cp /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
RUN echo "America/Sao_Paulo" >  /etc/timezone

RUN update-ca-certificates

ARG bundle_options_var='--without development test'

ENV APP_ROOT /app

RUN mkdir $APP_ROOT

WORKDIR $APP_ROOT

COPY Gemfile $APP_ROOT/Gemfile
COPY Gemfile.lock $APP_ROOT/Gemfile.lock

RUN gem install bundler
RUN bundle config --global frozen 1
RUN bundle install $bundle_options_var

COPY . $APP_ROOT

ENTRYPOINT ["bundle", "exec"]
CMD ["puma", "-C", "config/puma.rb"]
1 Like

A network problem. I’m being haunted by these lately, too. E.g. in https://travis-ci.org/skvark/opencv-python/builds/527582357 , 18 jobs failed due to network timeouts.

How to solve this problem?
Or is it not up to me?

We have very similar case in our case with pip installs:

https://travis-ci.org/apache/airflow/jobs/528104607 or https://travis-ci.org/apache/airflow/jobs/528104609 - also increased number of failures (20%/30% of our jobs) over the course of last few days.

It looks like a routing issues from the Travis build workers… I raised an issue with Travis support

2 Likes

Seems That Travis engineers are investigating it now with a possible workaround (not very helpful in our case) in the meantime: https://www.traviscistatus.com/incidents/kyf149kl6bvp?u=3g7kt113nmgs