See this guide on how /client and /server are set up with Heroku.
- Install Docker.
- Create
.envfile with contents in 1Password file. - Create
client/.env.localfile with the contents:
REACT_APP_HOSTNAME=http://localhost:3000
# Optional, to use local server for soundfont files (e.g. when developing with no internet connection)
REACT_APP_SOUNDFONT_HOSTNAME=http://localhost:3000/soundfonts
To run server at localhost:3001:
- Run
docker-compose build(to re-build the container, rundocker-compose build --no-cache) - Run
docker-compose up
To run the client at localhost:3000:
cd clientyarn installyarn start
Go to localhost:3000 to view the app.
- Upload your public ssh key to the droplet to be able to SSH into droplet with
ssh root@pianohub.io - Add your SSH key to dokku to be able to run
git push dokku master
- In this repo, add dokku remote:
git remote add dokku dokku@pianohub.io:pianohub - Deploy with
git push dokku master
The production server runs on localhost:5000, and port 5000 is necessary as the default exposed port for Dokku nginx.
Connecting to database
In development:
docker exec -it pianohub_postgres_1 psql postgres://pianohub_user:pianohub@localhost:5432/pianohub
In production, SSH into droplet and do:
dokku postgres:connect pianohub
Creating migrations
cd server
yarn run db:migrate-make add_column_to_tableRunning migrations and seed data
In development, re-run docker-compose build and docker-compose up, which will re-run migrations.
In production, SSH into droplet and do:
dokku run pianohub yarn run db:setup
First, set up Dokku on DigitalOcean
DigitalOcean configuration
Set up A records for www and @ which direct to the pianohub.io app.
Dokku configuration
SSH into droplet with ssh root@pianohub.io
Postgres DB setup:
- Add Postgres add-on by running
dokku plugin:install https://github.com/dokku/dokku-postgres.git - Run
dokku postgres:create pianohub - Set up
DATABASE_URLenv var by runningdokku postgres:link pianohub pianohub
Domain configuration:
- Add domains with
dokku domains:add pianohub pianohub.io www.pianohub.io - Use dokku-redirect to redirect from
pianohub.iotowww.pianohub.io:dokku redirect:set pianohub pianohub.io www.pianohub.io
Setting up https with dokku-letsencrypt and this guide:
dokku config:set --no-restart pianohub DOKKU_LETSENCRYPT_EMAIL=<email>dokku letsencrypt pianohubdokku letsencrypt:cron-job --add- Verify cron job with
crontab -l -u dokku
Set environment variables (specified in server/.env.template):
dokku config:set pianohub SESSION_KEY=<key> SMTP_HOST=<host> SMTP_PORT=<port> SMTP_AUTH_USERNAME=<username> SMTP_AUTH_PASSWORD=<password>
In development, check emails at https://ethereal.email/messages using SMTP_AUTH_USERNAME and SMPT_AUTH_PASSWORD set in .env.