Skip to content

Conversation

@nk-ty
Copy link
Contributor

@nk-ty nk-ty commented Oct 28, 2025

Apple Silicon Mac対応と開発環境の修正

概要

Apple Silicon Mac(M1/M2/M3)で開発環境が起動できない問題を修正しました。

問題

  • Debian Busterのサポート終了によりDockerビルドが失敗
  • MySQL 5.7.39がARM64に非対応
  • 開発環境でのGem管理とMySQL接続の問題

主な変更

1. Rubyバージョン更新

  • Ruby 3.0.0 → 3.0.7(Debian Bullseye)
  • Bundler 2.2.33に固定(Gemfile.lockとの互換性)

2. ARM64対応

  • 新規: docker-compose.with_mysql.arm.yml(MySQL 8.0使用)
  • Intel Macは従来のdocker-compose.with_mysql.yml(MySQL 5.7.39)を継続使用

3. 開発環境の改善

  • 新規: dev-entrypoint.sh(Gem自動インストール、MySQL待機処理)
  • 新規: .env.development(環境変数管理)
  • Puma設定: 開発環境ではTCPポート使用(Unixソケットのパーミッション問題回避)

4. Docker Compose v2対応

  • 全ファイルからversion: '3'を削除(obsolete警告の解消)

起動方法(Apple Silicon Mac)

export $(cat .env.development | xargs)
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.with_mysql.arm.yml up -d
docker exec -it bm-app rails db:create db:migrate

アクセス: http://localhost:3000

本番環境への影響

影響あり(要確認)

  • Dockerfile: Ruby 3.0.7へのアップグレード → 本番デプロイ前にテスト必須
  • Gemfile: Rubyバージョン指定の変更
  • db/schema.rb: Rails 7.0形式への自動更新、MySQL 8.0のcollation追加

影響なし

  • config/puma.rb: 環境変数で分岐(本番は従来通りUnixソケット)
  • docker-compose.dev.yml: 開発環境専用
  • dev-entrypoint.sh: 開発環境専用
  • .env.development: 開発環境専用(.gitignore追加推奨)

レビューポイント

  1. Ruby 3.0.0 → 3.0.7の互換性確認
  2. MySQL 5.7 vs 8.0の差異確認(本番環境のバージョン)
  3. config/puma.rbの環境変数分岐の妥当性
  4. .env.development.gitignore追加要否

参考資料

  • 詳細手順: docs/startup-guide-arm64.md

nk-ty added 4 commits October 28, 2025 12:46
Update Ruby to 3.0.7 and MySQL to 8.0 for better ARM64 compatibility, adjusting Gemfile, Dockerfile, and lockfile accordingly. Add dev-entrypoint.sh for gem installation and DB readiness, and docker-compose.with_mysql.arm.yml for Apple Silicon. Improve Puma config for dev, expose port 3000, and enhance .gitignore. Add ARM setup guide in docs.
Added explicit 'collation' options to table definitions for utf8mb4_0900_ai_ci and removed ActiveRecord version annotation for compatibility. This ensures consistent collation across all tables and aligns schema.rb with the latest structure. No changes to actual schema or data.
Switched from circleci/ruby:3.0.0-node to cimg/ruby:3.0.7-node for both jobs and improved cache keys to use Gemfile.lock. Changed dependency installation to use bundle config and bundle install steps, ensuring reproducible environments. Modified rubocop job to restore and save dependency cache for efficiency.
…ugins

Simplifies cops configuration, switches to new `plugins` keyword, enables all new cops globally, and updates namespaces for customizations. Removes explicit cop toggles now covered by `NewCops: enable`, aligning with RuboCop 1.52+ recommended style.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant