#やりたいこと
Dockerでrailsアプリを開発しており、Herokuへのデプロイ作業中につまづきました。
最終的には、git-hubプッシュすると自動的にテスト→herokuへデプロイとなるようにしたいです。
こちらの記事を参考に進めていました
[qiita]RailsアプリをDockerで作ってCircleCIで自動テストしてHerokuにデプロイした話
#エラー
#!/bin/bash -eo pipefail bundle install --path vendor/bundle Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. Your Ruby version is 2.6.3, but your Gemfile specified 2.5.3 Exited with code exit status 18 CircleCI received exit code 18 ```![イメージ説明](ad8b7fd5071eb695fabc2df4df4a208b.png) ###Dockerfile ```Dockerfile FROM ruby:2.5.3 RUN apt-get update -qq && apt-get install -y build-essential nodejs # chromeの追加 RUN apt-get update && apt-get install -y unzip && \ CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \ wget -N http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -P ~/ && \ unzip ~/chromedriver_linux64.zip -d ~/ && \ rm ~/chromedriver_linux64.zip && \ chown root:root ~/chromedriver && \ chmod 755 ~/chromedriver && \ mv ~/chromedriver /usr/bin/chromedriver && \ sh -c 'wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -' && \ sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' && \ apt-get update && apt-get install -y google-chrome-stable RUN mkdir /app WORKDIR /app COPY Gemfile /app/Gemfile COPY Gemfile.lock /app/Gemfile.lock RUN bundle install COPY . /app
###Docker-compose.yml
Docker
1version: '3' 2services: 3 web: 4 build: . 5 command: bundle exec rails s -p 3000 -b '0.0.0.0' 6 volumes: 7 - .:/app 8 ports: 9 - 3000:3000 10 depends_on: 11 - db 12 tty: true 13 stdin_open: true 14 15 #rspec導入の際に追加 16 selenium_chrome: 17 image: selenium/standalone-chrome-debug 18 logging: 19 driver: none 20 #追加ここまで 21 22 db: 23 image: mysql:5.7 24 volumes: 25 - db-volume:/var/lib/mysql 26 environment: 27 MYSQL_ROOT_PASSWORD: password 28volumes: 29 db-volume:
###.circleci/config.yml
version: 2 jobs: build: docker: - image: circleci/ruby:2.5.3-node-browsers environment: - BUNDLER_VERSION: 2.0.2 - RAILS_ENV: 'test' - image: circleci/mysql:5.7 environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'true' - MYSQL_ROOT_HOST: '127.0.0.1' - image: selenium/standalone-chrome-debug logging: driver: none working_directory: ~/app #自身のアプリディレクトリ名を設定 steps: - checkout - restore_cache: keys: - v1-dependencies-{{ checksum "Gemfile.lock" }} - v1-dependencies- - run: name: install dependencies command: | gem install bundler -v 2.0.2 bundle install --jobs=4 --retry=3 --path vendor/bundle - save_cache: paths: - ./vendor/bundle key: v1-dependencies-{{ checksum "Gemfile.lock" }} # Database setup - run: mv ./config/database.yml.ci ./config/database.yml # Database setup - run: name: Databasesetup command: | bundle exec rake db:create bundle exec rake db:schema:load # run tests! - run: name: Run rspec command: | mkdir /tmp/test-results TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \ circleci tests split --split-by=timings)" bundle exec rspec \ --format progress \ --out /tmp/test-results/rspec.xml \ --format progress \ $TEST_FILES # collect reports - store_test_results: path: /tmp/test-results - store_artifacts: path: /tmp/test-results destination: test-results - deploy: name: Deploy Master to Heroku command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master fi
###Gemfile
source
1git_source(:github) { |repo| "https://github.com/#{repo}.git" } 2 3ruby '2.5.3' 4 5# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 6gem 'rails', '~> 5.2.2' 7# Use mysql as the database for Active Record 8 9#変更前 10#gem 'mysql2', '>= 0.4.4', '< 0.6.0' 11 12 13#デプロイの際に変更 14gem 'mysql2', '>= 0.4.4', '< 0.6.0', groups: %w(test development), require: false 15gem 'pg', '~> 0.19.0', group: :production, require: false 16 17# Use Puma as the app server 18gem 'puma', '~> 3.11' 19# Use SCSS for stylesheets 20#gem 'sass-rails', '~> 5.0' 21gem 'sassc-rails' 22# Use Uglifier as compressor for JavaScript assets 23gem 'uglifier', '>= 1.3.0' 24# See https://github.com/rails/execjs#readme for more supported runtimes 25# gem 'mini_racer', platforms: :ruby 26 27# Use CoffeeScript for .coffee assets and views 28gem 'coffee-rails', '~> 4.2' 29# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 30gem 'turbolinks', '~> 5' 31# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 32gem 'jbuilder', '~> 2.5' 33# Use Redis adapter to run Action Cable in production 34# gem 'redis', '~> 4.0' 35# Use ActiveModel has_secure_password 36gem 'bcrypt', '~> 3.1.7' 37 38# Use ActiveStorage variant 39# gem 'mini_magick', '~> 4.8' 40 41# Use Capistrano for deployment 42# gem 'capistrano-rails', group: :development 43 44# Reduces boot times through caching; required in config/boot.rb 45gem 'bootsnap', '>= 1.1.0', require: false 46gem 'jquery-rails' 47gem 'jquery-ui-rails' 48gem 'bootstrap', '~> 4.0.0' 49gem 'mini_racer' 50gem 'rails-i18n', '~> 5.1' 51gem 'font-awesome-sass' 52gem 'cocoon' 53gem 'carrierwave' 54gem 'rqrcode' 55gem 'chunky_png' 56gem 'obfuscatable' 57gem 'nested_form_fields' 58gem "chartkick" 59gem 'devise' 60 61group :development, :test do 62 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 63 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 64 gem 'pry-byebug' 65 gem "rspec-rails" 66 gem "factory_bot_rails" 67 gem 'database_cleaner' 68end 69 70group :development do 71 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 72 gem 'web-console', '>= 3.3.0' 73 gem 'listen', '>= 3.0.5', '< 3.2' 74 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 75 gem 'spring' 76 gem 'spring-watcher-listen', '~> 2.0.0' 77 gem 'annotate' 78end 79 80group :test do 81 # Adds support for Capybara system testing and selenium driver 82 gem 'capybara', '>= 2.15' 83 gem 'selenium-webdriver' 84 # Easy installation and use of chromedriver to run system tests with Chrome 85 #gem 'chromedriver-helper' 86 #gem 'webdrivers' 87end 88 89# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 90#gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 91
#やったこと
ディレクトリ直下の.ruby-versionの中身もruby-2.5.3になっているのを確認しました。
dockerfileでもcircleciのconfig.ymlでもruby 2.5.3を指定しているのですが、エラーが出てしまい困っています。
ローカルでdocker-compose buildやupして動作確認する際には特にエラーもなく動いています。
#追記
ローカルでbundle instalをすると下のエラーメッセージがでました
Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
bundlerのあたりが悪さしているのかと思い、エラーメッセージの通りにコンテナ内で gem install bundler
を打ってみましたが、その後bundlerのバージョンを確認しても1.7.2のままになってしまってます。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/07/02 08:35
退会済みユーザー
2020/07/02 08:39
2020/07/02 09:24
2020/07/02 11:27