Skip to content

Instantly share code, notes, and snippets.

@julindra
Last active February 28, 2022 09:59
Show Gist options
  • Save julindra/fed01cb1b9c8efdc51dea49611ead34f to your computer and use it in GitHub Desktop.
Save julindra/fed01cb1b9c8efdc51dea49611ead34f to your computer and use it in GitHub Desktop.
Heroku & Firebase Hosting

Deploy Server -> Heroku

https://devcenter.heroku.com/articles/deploying-nodejs

  1. register & login ke heroku.com
  2. install heroku-cli (https://devcenter.heroku.com/articles/heroku-cli)
  3. lakuin di terminal heroku login
  4. bikin app di dashboard atau pakai command heroku create <namaapp>
  5. dari dashboard app ke resources - tambahin add on heroku postgres atau melalui command terminal
heroku addons:create heroku-postgresql:hobby-dev
  1. edit file package.json server tambah script "start": "node app.js"
  2. edit config.json production "use_env_variable": "DATABASE_URL"
  3. edit app.js port ganti jadi process.env.PORT || 3000
  4. tidak perlu require dotenv di production
  5. di dashboard ke settings, tambahin config vars sesuai .env
  6. tambah remote heroku melalui terminal heroku git:remote -a <namaapp>
  7. git add commit push dulu ke repo origin
  8. git push heroku master jika repo langsung server atau git subtree push --prefix server heroku master jika server berada di folder repo
  9. jika dapat error ssl off, edit config.json production tambahin
"dialectOptions": {
    "ssl": {
        "rejectUnauthorized": false
    }
}
  1. push lagi ke origin dan heroku
  2. jalanin command heroku run bash untuk masuk ke terminal heroku
  3. install sequelize-cli npm i -g sequelize-cli
  4. jalanin sequelize db:migrate atau sequelize db:seed:all
  5. kalau ada perubahan push lagi

Deploy Client -> Firebase

https://firebase.google.com/docs/hosting/quickstart

  1. install firebase cli npm install -g firebase-tools
  2. jalanin firebase login untuk connect ke akun
  3. masuk ke console.firebase.google.com, bikin new project
  4. masuk ke folder client, jalanin firebase init
  5. pilih pake tombol spasi firebase hosting
  6. pilih project existing atau new
  7. tulis folder yang mau dideploy, kalau udh di dalem folder client .. kalau nanti pakai vue, kemungkinan pakai folder dist
  8. configure as a single-page app -> yes
  9. File ./index.html already exists. Overwrite? -> no
  10. jalanin firebase deploy untuk deploy, ketika ada perubahan langsung firebase deploy juga
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment