0

I am trying to cache ruby gems locally for my docker to run faster.

I found this 8 months old post Configure cache on GitLab runner that talks about caching locally isn't possible. Is that still true or am I just doing it wrong?

My gitlab-ci.yml:

stages:
  - test
  
test:unit:
  stage: test
  image: ruby:2.5.8
  cache:
    key: gems
    untracked: true
    paths:
      - vendor/ruby
  services:
    - mysql:5.7
  variables:
    MYSQL_DB: inter_space_test
    MYSQL_USER: root
    MYSQL_ROOT_PASSWORD: root
    MYSQL_PASSWORD: ''
    MYSQL_HOST: mysql
    RAILS_ENV: test
  script:
    - bundle config set path 'vendor/ruby'
    - cp config/database.yml_ci config/database.yml
    - apt-get update && apt-get install -y nodejs
    - gem install bundler --no-document
    - bundle install -j $(nproc) --path vendor/ruby
    - ls -lah vendor/ruby/

    - bundle exec rake db:setup
    - bundle exec rake db:migrate
    - bundle exec rails test -d

my config toml

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "main"
  url = "https://gitlab.com/"
  token = "1r1op5jJARn8akjaG-hs"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "ruby:2.5.8"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    cache_dir = "/vendor/ruby"
    volumes = ["/cache", "/vendor/ruby", "/var/cache/apt"]
    shm_size = 300000
DV82XL
  • 5,350
  • 5
  • 30
  • 59
Peter J
  • 1
  • 4

1 Answers1

0

I fixed it.

Those two lines did it:

- export BUNDLE_PATH="/vendor/ruby"
- bundle config set path '/vender/ruby'
Peter J
  • 1
  • 4