5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Fly.ioにPhoenix PJ構築

Last updated at Posted at 2024-03-01

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に追加

lib/ymnb_web/router.ex
   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) 

この画面が表示します、Databaseを変更します
image.png

下記の用に変更しました
image.png

設定完了後Confirm Settingsをクリックします

下記の画面が表示後ブラウザを閉じます
image.png

その後の処理は下記の状態で完了です(時間かかります)
image.png

Visit your newly deployed app at https://任意の名前.fly.dev/が表示します

検証

https://任意の名前.fly.dev/にアクセス
image.png

https://任意の名前.fly.dev/usersにアクセス
image.png

New Userをクリック後Nameに文字を入力しSeve User
image.png

下記のようにの表示できました
image.png

fly.ioからAppの消し方

https://fly.io/ 
にアクセス
前提:ログイン済み

Dashboardをクリック
image.png

Settingsをクリック
image.png

消したいアプリをクリック
image.png

アプリ名を入力しYes,delete itをクリック
image.png

これで消えました
同様手順でdbも削除できます

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?