EC2内でマイグレーションファイルを贈ろうとしたところエラーが起きました、
rails s をやっても同じエラーがおきます。
ログを調べたところCould not find minitest-5.14.2 in any of the sources
とあったのでbundle update minitest したのですが治りませんでした。。
試したコマンド
bundle install
bundle update
bundle update minitest
エラー原因のminitestをgemgile.lookから消したのですが、
その他にも消かなくてはいけないパッケージがかなりあったのでやめました。
初めのエラー [ec2-user@ip-172-31-4-209 Books]$ rails db:migrate RAILS_ENV=production DEPRECATION WARNING: Including LoggerSilence is deprecated and will be removed in Rails 6.1. Please use `ActiveSupport::LoggerSilence` instead (called from <main> at /var/www/Books/config/application.rb:7) rails aborted! Mysql2::Error::ConnectionError: Unknown MySQL server host 'db' (2) /var/www/Books/bin/rails:9:in `<top (required)>' /var/www/Books/bin/spring:15:in `<top (required)>' bin/rails:3:in `load' bin/rails:3:in `<main>' Tasks: TOP => db:migrate (See full trace by running task with --trace)
Books % docker-compose ps Name Command State Ports --------------------------------------------------------------------------------------- books_db_1 docker-entrypoint.sh --def ... Up 0.0.0.0:4306->3306/tcp, 33060/tcp books_web_1 bash -c rm -f tmp/pids/ser ... Exit 1
Books % docker-compose logs db Attaching to books_db_1 2020-09-07T10:09:59.502935Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.21). db_1 | 2020-09-07T10:10:02.371623Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.21) MySQL Community Server - GPL. db_1 | 2020-09-07 13:12:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started. db_1 | 2020-09-07 13:12:26+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' db_1 | 2020-09-07 13:12:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started. db_1 | 2020-09-07T13:12:26.968837Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.21) starting as process 1 db_1 | 2020-09-07T13:12:26.993639Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. db_1 | 2020-09-07T13:12:27.422215Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. db_1 | 2020-09-07T13:12:27.629852Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock db_1 | 2020-09-07T13:12:27.812775Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. db_1 | 2020-09-07T13:12:27.812974Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. db_1 | 2020-09-07T13:12:27.815671Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. db_1 | 2020-09-07T13:12:27.859724Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.21' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
Books % docker-compose up Starting books_db_1 ... done Starting books_web_1 ... done Attaching to books_db_1, books_web_1 db_1 | 2020-09-07 13:36:52+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started. db_1 | 2020-09-07 13:36:52+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' db_1 | 2020-09-07 13:36:52+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started. db_1 | 2020-09-07T13:36:52.786290Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.21) starting as process 1 db_1 | 2020-09-07T13:36:52.797137Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. db_1 | 2020-09-07T13:36:53.077210Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. web_1 | bundler: failed to load command: rails (/usr/local/bundle/bin/rails) web_1 | Bundler::GemNotFound: Could not find minitest-5.14.2 in any of the sources web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/spec_set.rb:86:in `block in materialize' web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/spec_set.rb:80:in `map!' web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/spec_set.rb:80:in `materialize' web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:170:in `specs' web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:237:in `specs_for' web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:226:in `requested_specs' web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:101:in `block in definition_method' web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:20:in `setup' web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler.rb:149:in `setup' web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/setup.rb:20:in `block in <top (required)>' web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:136:in `with_level' web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:88:in `silence' web_1 | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/setup.rb:20:in `<top (required)>' db_1 | 2020-09-07T13:36:53.259743Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock books_web_1 exited with code 1 db_1 | 2020-09-07T13:36:53.403640Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. db_1 | 2020-09-07T13:36:53.404316Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. db_1 | 2020-09-07T13:36:53.408647Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. db_1 | 2020-09-07T13:36:53.453959Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.21' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
docker
1 docker-compose run web rails db:migrate RAILS_ENV=production 2Starting books_db_1 ... done 3Starting books_chrome_1 ... done 4Creating books_web_run ... done 5Could not find minitest-5.14.2 in any of the sources 6Run `bundle install` to install missing gems.
version: '3' services: db: image: mysql volumes: - ./tmp/db:/var/lib/mysql/data web: build: . command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - .:/Books ports: - "3000:3000" depends_on: - db - chrome stdin_open: true tty: true chrome: image: selenium/standalone-chrome:3.141.59-dubnium ports: - 4444:4444
dockerfile
1FROM ruby:2.6.3 2RUN apt-get update -qq && apt-get install -y nodejs postgresql-client yarn chromium-driver # yarnとchromium-driverを追記 3RUN mkdir /Books 4WORKDIR /Books 5COPY Gemfile /Books/Gemfile 6COPY Gemfile.lock /Books/Gemfile.lock 7RUN gem install bundler 8RUN bundle install 9COPY . /Books 10COPY entrypoint.sh /usr/bin/ 11RUN chmod +x /usr/bin/entrypoint.sh 12ENTRYPOINT ["entrypoint.sh"] 13EXPOSE 3000 14CMD ["rails", "server", "-b", "0.0.0.0"]
database.yml
1 2default: &default 3 adapter: mysql2 4 encoding: utf8 5 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 6 username: root 7 password: example 8 # socket: /tmp/mysql.sock 9 10 host: db 11 12development: 13 <<: *default 14 database: Books_development 15 16test: 17 <<: *default 18 database: Books_test 19 20production: 21 <<: *default 22 database: Books_production 23 24 username: root 25 password: <%= ENV['DATABASE_PASSWORD'] %> 26 # socket: /var/lib/mysql/mysql.sock
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/09/07 21:14
2020/09/08 00:48
2020/09/08 01:49
2020/09/08 02:14
2020/09/08 03:32
2020/09/08 03:39 編集