rspecを実行できない
$docker-compose run web rspec
を実行すると以下のエラーが発生します。
Failure/Error: ActiveRecord::Migration.maintain_test_schema! Mysql2::Error::ConnectionError: Access denied for user 'app_name'@'%' to database 'app_name'
関連するファイル
以下のファイル以外にも必要なファイルがあったら教えていただきたいです。
database.yml
# MySQL. Versions 5.1.10 and up are supported. default: &default adapter: mysql2 encoding: utf8mb4 charset: utf8mb4 collation: utf8mb4_bin pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: development: <<: *default database: app_name_development socket: /tmp/mysql.sock test: <<: *default database: app_name_test staging: <<: *default database: app_name_staging username: app_name password: <%= ENV['APP_NAME_DATABASE_PASSWORD'] %> production: <<: *default database: app_name_production username: art-app_name password: <%= ENV['APP_NAME_AR_DATABASE_PASSWORD'] %>
docker-compose.yml
version: "3.6" services: db: image: mysql:5.7 command: mysqld #--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci environment: TZ: "Asia/Tokyo" MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: app_name_development MYSQL_USER: app_name MYSQL_PASSWORD: app_name volumes: - ./docker/db/multibyte.cnf:/etc/mysql/conf.d/multibyte.cnf ports: - "13306:3306" webpacker: build: . command: ./bin/webpack-dev-server # command: /bin/bash -c 'rm -rf public/packs || true && bin/webpack-dev-server' volumes: - .:/app - node_modules:/app/node_modules - bundle:/usr/local/bundle ports: - "3035:3035" environment: RAILS_ENV: "development" NODE_ENV: "development" WEBPACKER_DEV_SERVER_HOST: "0.0.0.0" WEBPACKER_DEV_SERVER_PUBLIC: "0.0.0.0:3035" web: build: . command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - .:/app - node_modules:/app/node_modules - bundle:/usr/local/bundle ports: - "3000:3000" environment: TZ: "Asia/Tokyo" RAILS_ENV: "development" DATABASE_URL: "mysql2://app_name:app_name@db" WEBPACKER_DEV_SERVER_HOST: "webpacker" WEBPACKER_DEV_SERVER_PUBLIC: "webpacker:3035" depends_on: - db - webpacker tty: true stdin_open: true volumes: mysql-data: bundle: node_modules:
回答1件
あなたの回答
tips
プレビュー