-
Notifications
You must be signed in to change notification settings - Fork 4
Deployment
SAITOU Keita edited this page Apr 1, 2025
·
5 revisions
https://fly.io/docs/hands-on/install-flyctl/
- 画像をアップロードするためのCloudinary、ユーザー認証の際に使うメーラーを、credentialsを使って設定する。
$ rm config/credentials/production.yml.enc config/credentials/production.key # デフォルトの設定の削除
$ bundle exec rails credentials:edit --environment production
...編集画面が開く
# config/credentials/production.yml.encの設定例
# email configuration to reset password by email
mail:
smtp: "smtp.gmail.com"
domain: "gmail.com"
port: 587
user_name: "[YOUR MAIL ADDRESS]@gmail.com"
password: "[YOUR MAIL PASSWORD]"
# cloudinary configuration to save image
cloudinary:
cloud_name: [YOUR CLOUD NAME]
api_key: [YOUR API KEY]
api_secret: [YOUR API SECRET]
enhance_image_tag: true
static_file_support: false
# Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies.
secret_key_base: [Rails_secret_key_base_XXXXXXXXXXXXXXXXXXXXXXXXXXXX]
- Credentials の Key を fly に登録する
$ fly secrets set RAILS_MASTER_KEY=$(cat config/credentials/production.key)
...
$ fly deploy --dockerfile fly.Dockerfile -build-arg RUBY_VERSION="$(cat .ruby-version)"
...
SAKAZUKI の Production 環境は Heroku を対象にしている。 このとき SAKAZUKI は画像を Cloudinary にアップロードする。 SAKAZUKI を Heroku で動かすには、メールと Cloudinary の設定がいる。 これらの設定は Rails の credentials を使って設定する。
$ rm config/credentials/production.yml.enc config/credentials/production.key # デフォルトの設定の削除
$ bundle exec rails credentials:edit --environment production
...編集画面が開く
# config/credentials/production.yml.encの設定例
mail:
smtp: "smtp.gmail.com"
domain: "gmail.com"
port: 587
user_name: "[YOUR MAIL ADDRESS]@gmail.com"
password: "[YOUR MAIL PASSWORD]"
cloudinary:
cloud_name: [YOUR CLOUD NAME]
api_key: [YOUR API KEY]
api_secret: [YOUR API SECRET]
enhance_image_tag: true
static_file_support: false
- Credentials の Key を Heroku に登録
- heroku-cli が必要
$ heroku config:set RAILS_MASTER_KEY=$(cat config/credentials/production.key)
...
- Heroku に SAKAZUKI をデプロイする