Brightの対象
Webアプリ開発 Elixir > クラス1 > Elixir環境構築 > クラウド > Fly.ioにPhoenix PJ構築
前提
fly.ioのアカウント登録済みであること
└クレジットカード登録済みであること
flyctlをインストール (Linux)
$ curl -L https://fly.io/install.sh | sh
他のOSはこちらを参考にしてください
https://fly.io/docs/hands-on/install-flyctl/
Phoenix PJを構築
前提:ymnbの部分は適宜変更してください
$ mix phx.new ymnb
Fetch and install dependencies? [Yn] Y
と聞かれるのでY
$ cd ymnb
$ mix phx.gen.live Accounts User users name:string
router.exのscope "/", YmnbWeb doに追加
scope "/", YmnbWeb do
pipe_through :browser
get "/", PageController, :home
+ live "/users", UserLive.Index, :index
+ live "/users/new", UserLive.Index, :new
+ live "/users/:id/edit", UserLive.Index, :edit
+ live "/users/:id", UserLive.Show, :show
+ live "/users/:id/show/edit", UserLive.Show, :edit
end
fly.io構築
前提:コマンドラインでfly.ioにログイン済みであること fly auth login
$ fly launch
下記のエラーはでますがローカルにPostgrを構築してないので表示します
が今回はfly.ioでの構築の為無視します
[error] Postgrex.Protocol (#PID<0.441.0>) failed to connect: **
(DBConnection.ConnectionError)
tcp connect (localhost:5432): connection refused - :econnrefused
↓これを聞かれるのでy
Do you want to tweak these settings before proceeding? (y/N)
設定完了後Confirm Settingsをクリックします
Visit your newly deployed app at https://任意の名前.fly.dev/
が表示します
検証
https://任意の名前.fly.dev/users
にアクセス
New Userをクリック後Nameに文字を入力しSeve User
fly.ioからAppの消し方
https://fly.io/
にアクセス
前提:ログイン済み
これで消えました
同様手順でdbも削除できます