LoginSignup
0
0

More than 1 year has passed since last update.

備忘録:herokuについて

Last updated at Posted at 2021-06-29

heorkuにてアプリケーションを立ち上げるのに丸二日苦労したので忘れないように残しておく。

基本的な流れ
1.herokuでデータベースなどをセットアップ
2.公開したいアプリケーションをgithubなどからローカルにプル
3.ローカルからコミット&プッシュ

1について
herokuでアプリケーションを作成しデータベースを作成
ブラウザでアプリをcreateしたらresourcesのfind-more-addonsでポスグレを追加
アプリケーションのsettingで以下の${}に対応するkeyとvalueを設定

spring.datasource.url=${DATABASE_URL}
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}

2について
自分のpc上で任意のディレクトリを作成しそこにgithubなどから公開したいアプリケーションをプル
pom.xmlがある階層まで降りたらherokuにログイン
以下のコマンドをcmdかpowershellで実行

heroku login

次に以下のコマンドでherokuのリモートリポジトリをherokuという名前で登録

git remote add heroku <herokuのgitあどれす>

commitする

heroku git:remote -a <app-name>

javaのbuildpacksをセットする

heroku buildpaks:set heroku/java

herokuはデフォルトでjdk8でビルドするらしいのでjdk8以外を使っている場合はpom.xmlと同じ改装にsystem.propertiesというファイルを置いて以下の内容を書きこむ

java.runtime.version=11

私はjdk11を使用していたので上記の内容をかいた

そしたら次に以下のコマンドをたたく

git add .
git commit -am "commit message"
git push heroku master

これで公開できる

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