my last post on deploying the FSA Twitter.js project was well received. well, here’s the FSA wikistack version!
prerequisites: go through the official heroku guide here to get a simple overview of what we will be doing: https://devcenter.heroku.com/articles/getting-started-with-nodejs
another good general instruction guide is on the sequelize
documentation itself! https://sequelize.readthedocs.io/en/1.7.0/articles/heroku/
The following specifically deals with deploying FSA wikistack.
Steps
assuming you have started from a clean wikistack local build:
heroku login
heroku create myAppName
- get rid of nodemon in your package.json scripts:
"start": "node index.js"
- replace your port with
process.env.PORT
inindex.js
:app.listen(process.env.PORT || 3001, function () {
heroku addons:create heroku-postgresql:hobby-dev
- explanation here: https://devcenter.heroku.com/articles/getting-started-with-nodejs#provision-a-database and you can check the URL withheroku config
- replace your db connection with
process.env.DATABASE_URL
in models/index.js:var db = new Sequelize(process.env.DATABASE_URL || 'postgres://localhost:5432/wikistack', { logging: false });
- this is a temporary wikistack issue - downgrade your
pg
requirement in package.json to"pg": "^4.5.3",
- deal with https issues: replace your boostrap js and css with https versions https://www.bootstrapcdn.com/
heroku pg:psql
andcreate table wikistack
to initialize the table. exit with\q
(what is it with CLI designers and shitty quit commands)git commit -am "deploy to heroku"
andgit push heroku master
I deployed my example at https://swyx-wikistack.herokuapp.com
i faced a problem with git commit -am
and git add . && git commit -m
. wont repeat that again.