どのようにデプロイしたか 基本的にはこちらの記事を参考にした。

Fly.ioにデプロイしてみた - Qiita

ポスグレとredisの所はNoにした。

その1

デプロイは上手くいったけど、なぜかリンクが開けなかった。(502のエラーが出た。)

エラー内容

ざっくりいうと デプロイされたアプリは期待されるアドレスでリッスンしていないため、**fly-proxy**によってアクセスされなかったことが原因っぽい。

`No machines in group app, launching a new machine`
`Machine 148e440c371989 [app] update finished: success`

`WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.`

`You can fix this by configuring your app to listen on the following addresses:`

`- 0.0.0.0:3000`

`Found these processes inside the machine with open listening sockets:`

`PROCESS        | ADDRESSES`

- `----------------*----------------------------------------`

`/.fly/hallpass | [fdaa:2:e259:a7b:b4f0:e735:d811:2]:22`

`Creating a second machine to increase service availability`

`Machine 6e82d4d5be7ed8 [app] update finished: success`

`Finished launching new machines`

`NOTE: The machines for [app] have services with 'auto_stop_machines = true' that will be stopped when idling`

`Visit your newly deployed app at <https://n46forever.fly.dev/`>

どのように解決したか

アプリケーションが期待されるアドレスでリッスンするように以下の二つのファイルを調整。

Fly.toml

before

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]

after

[http_service]
internal_port = 3000
address = "0.0.0.0" #追加
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]

Dockerfile

Railsアプリケーションをデプロイするための設定を修正。

before

CMD ["./bin/rails", "server"]