Upgrade to Pro — share decks privately, control downloads, hide ads and more …

【GAE、CloudSQL】Elixir/Phoenixで開発したDBアプリをGAEにデプロイ

KrainNeun
February 14, 2019

 【GAE、CloudSQL】Elixir/Phoenixで開発したDBアプリをGAEにデプロイ

KrainNeun

February 14, 2019
Tweet

Other Decks in Programming

Transcript

  1. GoogleCloudSDK のインストール・初期化 公式サイト を参考に導入します ローカルからCloudSQL に接続 ※CloudSQLProxy 公式サイト を参考にCloudSQLProxy を導入します

    これだけです。権限設定が少し大変です!! # UNIX ソケットの場合のプロキシ開始 sudo mkdir /cloudsql; sudo chmod 777 /cloudsql ./cloud_sql_proxy -dir=/cloudsql -instances=<INSTANCE_CONNECTION # プロキシへの接続 psql "sslmode=disable host=/cloudsql/<INSTANCE_CONNECTION_NAME>
  2. Elixir プロジェクト作成 Elixir プロジェクトを作成します。 mix phx.new gae_cloudsql_ex_phx --no-brunch DB 接続情報を修正します。※password

    とsocket_dir config :gae_cloudsql_ex_phx, GaeCloudsqlExPhx.Repo, adapter: Ecto.Adapters.Postgres, username: "postgres", password: ※CloudSQL のユーザパスワード, # ここ database: "gae_cloudsql_ex_phx_dev", socket_dir: "/cloudsql/<INSTANCE_CONNECTION_NAME>", # ここ pool_size: 10
  3. Elixir プロジェクト作成 簡単なAPI を作成し、Migrate 実行します。 mix phx.gen.json Api Test tests

    subject:text ~ 略~ mix ecto.migrate Migrate を実行後、CloudSQL を確認します。 DataBase が作成されていますね!