質問させて頂きます。
こちらの記事を元にhttps://www.youtube.com/watch?v=Fq1PH0Gwi8I
DockerにてRailsの開発環境を構築しようとしているのですが、
docker-compose up
でコンテナを起動させようとすると
Could not find gem 'mysql2 (>= 0.4.4, < 0.6.0)' in any of the gem sources listed in your Gemfile.
web_1 | Run bundle install
to install missing gems.
sample_app_web_1 exited with code 7
というエラー文が出てしまい、起動できません。
mysqlがないよと言われているのでしょうか?
mysql2のインストールをしようとしても今度はrailsのバージョンが違うと言われたりと混乱しております・・・
5ヶ月前の記事を参考にしているから今と挙動が変わっているのでしょうか?
どなたか教えて頂けますと幸いです。
以下コードを掲載します。
【docker-compose.yml】
version:
1 2# サービスの定義 3services: 4 db: 5 image: mysql:5.7 6 environment: 7 MYSQL_USER: root 8 MYSQL_ROOT_PASSWORD: password 9 ports: 10 - "3306:3306" 11 volumes: 12 - ./db/mysql/volumes:/var/lib/mysql 13 14 web: 15 # 同じディレクトリ配下にあるDockerfileをビルド 16 build: . 17 command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" 18 # ローカルPCのディレクトリをrubyコンテナにマウント 19 volumes: 20 - .:/myapp 21 - gem_data:/usr/local/bundle 22 # アプリ公開ポートを指定<公開ポート番号>:<コンテナ内の転送先ポート> 23 ports: 24 - 3000:3000 25 depends_on: 26 - db 27 # デバッグに使用するため設定 28 tty: true 29 stdin_open: true 30 31# マウントするデータ領域を指定 32volumes: 33 gem_data: 34 35
【Gemfile】
source
1git_source(:github) { |repo| "https://github.com/#{repo}.git" } 2 3ruby '2.5.8' 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 8gem 'mysql2', '>= 0.4.4', '< 0.6.0' 9# Use Puma as the app server 10gem 'puma', '~> 3.11' 11# Use SCSS for stylesheets 12gem 'sass-rails', '~> 5.0' 13# Use Uglifier as compressor for JavaScript assets 14gem 'uglifier', '>= 1.3.0' 15# See https://github.com/rails/execjs#readme for more supported runtimes 16# gem 'mini_racer', platforms: :ruby 17 18# Use CoffeeScript for .coffee assets and views 19gem 'coffee-rails', '~> 4.2' 20# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 21gem 'turbolinks', '~> 5' 22# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 23gem 'jbuilder', '~> 2.5' 24# Use Redis adapter to run Action Cable in production 25# gem 'redis', '~> 4.0' 26# Use ActiveModel has_secure_password 27# gem 'bcrypt', '~> 3.1.7' 28 29# Use ActiveStorage variant 30# gem 'mini_magick', '~> 4.8' 31 32# Use Capistrano for deployment 33# gem 'capistrano-rails', group: :development 34 35# Reduces boot times through caching; required in config/boot.rb 36gem 'bootsnap', '>= 1.1.0', require: false 37 38group :development, :test do 39 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 40 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 41end 42 43group :development do 44 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 45 gem 'web-console', '>= 3.3.0' 46 gem 'listen', '>= 3.0.5', '< 3.2' 47 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 48 gem 'spring' 49 gem 'spring-watcher-listen', '~> 2.0.0' 50end 51 52group :test do 53 # Adds support for Capybara system testing and selenium driver 54 gem 'capybara', '>= 2.15' 55 gem 'selenium-webdriver' 56 # Easy installation and use of chromedriver to run system tests with Chrome 57 gem 'chromedriver-helper' 58end 59 60# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 61gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 62 63
【Dockerfile】
FROM
1RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs 2 3 4RUN mkdir /myapp 5WORKDIR /myapp 6 7COPY Gemfile /myapp/Gemfile 8COPY Gemfile.lock /myapp/Gemfile.lock 9 10RUN bundle install 11COPY . /myapp 12 13
あなたの回答
tips
プレビュー