Heroku 佈署簡易網站
日期:2019/12/15
講者:王譽錚
Outline
- 什麼是heroku
- Git設定
- 實作
- 參考資源
什麼是 heroku ?

Heroku是一個支援多種程式語言的雲平台即服務

所支援的程式語言有:Ruby、Java、Node.js、Scala、Clojure、Python、PHP和Perl
優點 | 缺點 |
---|---|
提供免費帳戶每個月450個小時的運行時間。 如果開通信用卡,會額外增加 550 個小時的免費時數。 |
免費版每 30 分鐘未使用都會休眠一次。 |

Git設定
使用者設定
$ git config --global user.name "Your Name"
$ git config --global user.email "youremail@gmail.com"
$ cd 切換到檔案所在的目錄
$ git init
git初始化
實作
$ heroku login
登入 heroku

$ npm init
npm init

輸入你的js檔名

加入start
$ heroku create 你的app名稱
//app名稱只能有小寫跟破折號
建立 app
//命名不符合規則訊息
Name must start with a letter, end with a letter or digit and
can only contain lowercase letters, digits, and
! dashes.
//命名重複訊息
! Name it-just-try is already taken
//命名成功訊息
Creating sirla-chatbot... done
https://sirla-chatbot.herokuapp.com/ |
https://git.heroku.com/sirla-chatbot.git
添加 Buildpacks


$ heroku git:remote -a 你的APP名稱
set git remote heroku to https://git.heroku.com/it-just-try.git
設定要推到哪一個app
$ git add --all
將所有檔案都放置到暫存區
$ git commit -m "訊息內容"
[master (root-commit) 771a58c] 5
3 files changed, 31 insertions(+)
create mode 100644 .DS_Store
create mode 100644 HelloWord.js
create mode 100644 package.json
將檔案從暫存區提交到倉庫中
$ git push heroku master
To https://git.heroku.com/it-just-try.git
* [new branch] master -> master
將檔案上傳到指定的app
heroku open
開啟app


參考資源
Heroku安裝教學:https://ericjhang.github.io/archives/689940fd.html
發布網站到heroku:
https://ithelp.ithome.com.tw/articles/10196129
Heroku | 搭配 Git 在 Heroku 上部署網站的手把手教學:https://reurl.cc/Qpg7r0
END
heroku
By arashi
heroku
- 122