- Create heroku Account (https://www.heroku.com)
- Install heroku
- Heroku login:
heroku login
Use enviroment variables for ports and urls!
Set environment variables for Angular projects in
environment.prod.ts
and use withenvironment.warehouseURL
Set environment variables for node projects on heroku (https://heroku.com -> Project Overview -> Settings -> Reveal Config Vars) and use with
process.env.shopBackendUrl
- Create new git repo for every single application:
git init
- Make sure there's a .gitignore
- Copy neccessary dependencies (typescript, ...) from devDependencies to dependencies (in
package.json
) - use ports given by heroku (e.g. in app.ts):
const port = Number(process.env.PORT || oldPortForLocalTesting)
- use urls from heroku instad of localhost... (use env variables)
- e.g.
shopURL: = process.env.shopBackendUrl || 'http://localhost:5001/warehouse2shop'
- e.g.
- Commit all changes to git
- run
heroku create APP_NAME
- push changes to git:
git push heroku master
Find errors or console outputs with:
heroku logs
- on heroku page for the current project click on Configure Add-ons
- search for Heroku Postgres
- Select Hobby Dev - Free
- The DATABASE_URL is automatically configured as env variable
- in ormconfig.ts add:
url : process.env.DATABASE_URL || 'postgres://user:password@localhost:port/dbName'
- remove host, port, username, password, database properties
- ng serve does not work! Angular project needs to be compiled and then served from a simple static node webserver
- Change npm Scripts (in
package.json
)build: "ng build --prod"
start: "node server.js"
- Create
server.js
file in project root for serving local files- Use this template: https://gist.github.com/superjojo140/6977a42d0c2cb7a48f47f083144bfd04
- Install express:
npm install express