LoginSignup
7
5

More than 3 years have passed since last update.

cloud9からHerokuにデプロイ

Posted at

はじめに

cloud9で作ったサービスをHerokuにデプロイするながれを書いていきます。

実践

cloud9で環境構築、App作成後以下のものを設定します。(初回のみ実行します)

$ git config --global user.name "Your Name"
$ git config --global user.email your.email@example.com

このgit configで設定する名前やメールアドレスは、今後リポジトリ上で一般に公開されますのでご注意ください。

今回作ったモノのディレクトリに移動しgit initを実行します。

$ git init

次にgit add -Aを実行し、プロジェクトのファイルをリポジトリに追加します。

$ git add -A

ステージングエリアで控えている変更を本格的にリポジトリに反映 (コミット) するには、commitコマンドを使います。

$ git commit -m "Initialize repository"

新しいターミナルを開いて以下を実行します。

$ cd ~/.ssh

ssh-keygenはユーザー名、パスワードを聞かれますがすべてEnterキーを押せばデフォルトになります。

$ ssh-keygen

下記のコードで作成した公開鍵を確認することができます。

$ cat ~/.ssh/id_rsa.pub

cloud9にHerokuをインストールします。

$ source <(curl -sL https://cdn.learnenough.com/heroku_install)

Herokuのコマンドラインインターフェイス (CLI) がインストールされていることが確認できたら、いよいよherokuコマンドでログインしてSSHキーを追加します。

$ heroku login --interactive
$ heroku keys:add

最後にheroku createコマンドを実行して、Herokuサーバーにサンプルアプリケーションの実行場所を作成します。

$ heroku create 【アプリ名】
$ git push heroku master

以下のようなURLが発行されれば完了です。
https://xxxxx-xxxxx-xxxxx.herokuapp.com/

7
5
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
7
5