Rails 本番化対応 (rack-cors / /healthz / Dockerfile.production)#20
Merged
Conversation
This was
linked to
issues
May 8, 2026
9da5f9a to
3b7036d
Compare
48d691f to
dd00202
Compare
3b7036d to
a9a7304
Compare
dd00202 to
474d6ee
Compare
a9a7304 to
ea6df28
Compare
474d6ee to
6a36211
Compare
ea6df28 to
45015a3
Compare
6a36211 to
213df1a
Compare
45015a3 to
a0c5cb7
Compare
213df1a to
ec82b9b
Compare
a0c5cb7 to
66be6ac
Compare
…st_authorization)
CORS_ALLOWED_ORIGINS をはじめとする環境変数を .env で管理できるようにする。 bin/rails s にコマンドライン引数不要。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ec82b9b to
2648f9d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Rails 7 (API only) を本番環境で動かせる状態に整えました。
実装内容
1. rack-cors 追加
CORS_ALLOWED_ORIGINS環境変数でカンマ区切りパース/api/*リソースに対してのみ許可(GET / OPTIONS / HEAD)2. /healthz ヘルスチェックエンドポイント
{"status":"ok"}{"status":"error"}+Rails.logger.warn3. production.rb 本番対応
config.force_ssl = trueを有効化config.ssl_optionsで/healthzだけ HTTPS リダイレクトを除外(ALB 内部 HTTP チェック対応)config.host_authorizationで/healthzだけ検証を skipconfig.require_master_key = falseを明示4. database.yml 簡素化
adapter / encoding / poolのみに簡素化DATABASE_URL環境変数で接続先を制御5. Dockerfile.production (マルチステージビルド)
RAILS_ENV=productionを明示6. README 更新
/healthzエンドポイント説明テスト結果
関連 Issue
🤖 Generated with Claude Code