Deploy to Heroku - mzogheib/quoll GitHub Wiki
Prerequisits
- Install
heroku
globally and login
npm install -g heroku
heroku login
Initial Setup
-
Create an app for each package:
heroku create quoll-api --remote heroku-quoll-api heroku create quoll-client --remote heroku-quoll-client
-
Add a Procfile for each, with:
// packages/api/Procfile web: node server.js // packages/client/Procfile web: bin/boot
-
Add buildpacks. The monorepo one needs to be "defined first". Or add via the Heroku Dashboard.
heroku buildpacks:add -a quoll-api https://github.com/lstoll/heroku-buildpack-monorepo heroku buildpacks:add -a quoll-client https://github.com/lstoll/heroku-buildpack-monorepo heroku buildpacks:add -a quoll-api https://github.com/heroku/heroku-buildpack-nodejs heroku buildpacks:add -a quoll-client mars/create-react-app
https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-nodejs
https://elements.heroku.com/buildpacks/lstoll/heroku-buildpack-monorepo
https://elements.heroku.com/buildpacks/mars/create-react-app-buildpack
-
Then add this config variable to each app.
// in quoll-api APP_BASE=packages/api // in quoll-client APP_BASE=packages/client
-
Add any other config (env) variables required to run the app. Create React App env variables are prefixed with
REACT_APP_
. -
Make some changes and commit them.
-
Deploy to Heroku.
# If on master git push heroku-quoll-api master git push heroku-quoll-client master # If another branch git push heroku-quoll-api another-branch:master git push heroku-quoll-client another-branch:master
-
For some reason
api
needs to manually start the server...? https://stackoverflow.com/questions/11405826/error-h14-no-web-processes-running-deploy-on-heroku.heroku ps:scale web=1 --remote heroku-quoll-api
References
- https://medium.com/inato/how-to-setup-heroku-with-yarn-workspaces-d8eac0db0256
- https://michaellin.me/deploy-multiple-apps-in-monorepo-to-heroku/
- https://jaketrent.com/post/deploy-lerna-packages-heroku/
Force a redeploy
- Sometimes you may want to redeploy the apps even though no code changes were made.
- Create an empty commit and deploy.
git commit --allow-empty -m "chore: force deploy" --no-verify
git push heroku-quoll-client master
git clone
to a new machine or folder
After a - First, check your remotes. If a heroku remote(s) already exists then ... deal with it
git remote -v
- Set up the remotes
git remote add heroku-quoll-api https://git.heroku.com/quoll-api.git
git remote add heroku-quoll-client https://git.heroku.com/quoll-client.git
- Go through the deploy step above as normal