Skip to content

Instantly share code, notes, and snippets.

@tphdev
Created October 11, 2018 01:04
Show Gist options
  • Save tphdev/52f27b036fea998ad57063b847d4307d to your computer and use it in GitHub Desktop.
Save tphdev/52f27b036fea998ad57063b847d4307d to your computer and use it in GitHub Desktop.
Heroku Deploy
1) Create Heroku Account
- https://signup.heroku.com/dc
2) Install Heroku CLI
- https://devcenter.heroku.com/articles/heroku-cli#download-and-install
3) Create Heroku App
- heroku create «your app name»
- check `heroku -v`
4) Create Postgres database for app
- `add-on- heroku addons:create heroku-postgresql:hobby-dev`
5) Deploy Heroku App
6) Additional Steps
- `knexfile.js`
```js
// ...
const productionConfig = Object.assign(
{},
devConfig,
{ connection: process.env.DATABASE_URL }
)
module.exports = process.env.NODE_ENV === 'production' ? productionConfig : devConfig
```
- `server.js`
```js
const PORT = process.env.NODE_ENV === 'production' ? process.env.PORT : 3000
//....
const appDb = knex( dbConfigObj )
```
7) Migrations + Seeds
```
heroku run knex migrae:latest
heroku run knex seed:run
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment