Skip to content

Deployment

SAITOU Keita edited this page Apr 1, 2025 · 5 revisions

How to deploy to fly.io

Install flyctl(初回のみ)

https://fly.io/docs/hands-on/install-flyctl/

setting credentials(初回のみ)

  1. 画像をアップロードするための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]
  1. Credentials の Key を fly に登録する
$ fly secrets set RAILS_MASTER_KEY=$(cat config/credentials/production.key)
...

deploy

$ fly deploy --dockerfile fly.Dockerfile -build-arg RUBY_VERSION="$(cat .ruby-version)"
...

How to deploy to Heroku (old ver)

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 をデプロイする
Clone this wiki locally