Got it running perfectly at as of April 2021 ourbigbook.com with the following steps.
Initial setup for a Heroku project called ourbigbook:
sudo snap install --classic heroku
heroku login
heroku git:remote -a ourbigbook
git remote rename heroku prod
# Automatically sets DATABASE_URL.
heroku addons:create -a ourbigbook heroku-postgresql:hobby-dev
# We need this to be able to require("ourbigbook")
heroku config:set -a ourbigbook SECRET="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 256)"
# Password of users generated with ./web/bin/generate-demo-data
heroku config:set -a ourbigbook OURBIGBOOK_DEMO_USER_PASSWORD="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 20)"
# You can get it later to login with the demo users from the Heroku web interface
To finish things off, you must now:
Additionally, you also need to setup the PostgreSQL test database for both OurBigBook CLI and OurBigBook Web as documented at: test system and local run as identical to deployment as possible, because we will be running tests on PostgreSQL before pushing:
createdb ourbigbook
createdb ourbigbook_cli
psql -c "CREATE ROLE ourbigbook_user with login password 'a'"
psql -c 'GRANT ALL PRIVILEGES ON DATABASE ourbigbook TO ourbigbook_user'
psql -c 'GRANT ALL PRIVILEGES ON DATABASE ourbigbook_cli TO ourbigbook_user'
Then deploy with:
cd web
npm run deploy-prod
Get an interactive shell on the production server:
heroku run -a ourbigbook bash
From there you could then for example update the demo data with:
cd web
bin/generate-demo-data.js --force-production
This should in theory not affect any real user data, only the demo articles and users, so it might be safe. In theory!
Alternatively, we could do this at once with;
heroku run -a ourbigbook web/bin/generate-demo-data.js --force-production
Drop into a PostgreSQL shell on production:
heroku psql -a ourbigbook
Of course, any writes could mean loss of user data!
Run a query directly from your terminal:
heroku psql -a ourbigbook -c 'SELECT username,email FROM "User" ORDER BY "createdAt" DESC LIMIT 50'
If some spurious bugs crashes the server, you might want to restart it with:
heroku restart -a ourbigbook
Download a dump of the database as per devcenter.heroku.com/articles/heroku-postgres-import-export:
heroku pg:backups:capture -a ourbigbook
heroku pg:backups:download -a ourbigbook
Restore it to a local database:
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U ourbigbook_user -d ourbigbook latest.dump
The local password is a (single letter). TODO automate login.

Ancestors