Post

Deployment with Heroku CLI

Deployment with Heroku CLI

  1. Install Heroku CLI

    Ubuntu / Debian apt-get

    1
    
    $ curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
    

    npm

    1
    
    $ npm install -g heroku
    

    Check installed version

    1
    
    $ heroku --version
    
  2. Login Heroku

    1
    
    $ heroku login
    

    Close browser after login success

  3. Push code to Heroku

    1
    2
    
    $ heroku git:remote -a paoloc-nomadcoffee-backend
    $ git push heroku master
    
  4. Check Server logs

    1
    
    $ heroku logs --tail
    

Prisma Migrate to Heroku

Now a the server is deployed on Heroku, but database does not exist on the server. By following these steps, you will add a Postgres database and get migrate of the database schema.

  1. Go to Resources tap

  2. Search Postgres on Add-ons search and choose Heroku Postgres Select the Plan name (Hobby Dev - Free)

  3. Add Procfile on the root

    1
    2
    
    release: npx prisma migrate deploy
    web: npm start
    
  4. Push the changes to Heroku

    1
    
    $ git push heroku master
    

Add GitHub Deployment method

This configuration will deploy the heroku server automatically when the master branch of the project repository updated.

  1. Go to Deploy tap

  2. Select GitHub on Deployment method

  3. Add App connected to GitHub and select project repository

  4. Click Enable Automatic Deploys on Automatic deploys

References:

This post is licensed under CC BY 4.0 by the author.