Skip to content

Latest commit

 

History

History
184 lines (123 loc) · 3.75 KB

backend_deployment.md

File metadata and controls

184 lines (123 loc) · 3.75 KB

Heroku Deployment Setup

This document outlines the steps to deploy the Healthcare Assistant application to Heroku using Docker and Heroku Postgres. It includes environment variable configuration, Docker setup, and troubleshooting common issues.

Prerequisites

  • A Heroku account
  • Heroku CLI installed in terminal

Creating Heroku account

  1. Go to Heroku and sign up for an account.
  2. Verify your email address and log in to your account.

Installing Heroku CLI

Run the following command in your terminal to install the Heroku CLI:

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

To login to your Heroku account, run the following command:

heroku login

Go to the Heroku CLI page.

Deploying the Healthcare Assistant application

  • Create a new heroku app:
heroku create healthcare-assistant-app
  • Set the Heroku stack to container:
heroku stack:set container --app healthcare-assistant-app
  • Add the Heroku Postgres add-on:
heroku addons:create heroku-postgresql:essential-0 --app healthcare-assistant-app
  • Get the Heroku Postgres database URL:
heroku config:get DATABASE_URL --app healthcare-assistant-app
  • Set the environment variables:
heroku config:set DATABASE_URL=$(heroku config:get DATABASE_URL --app healthcare-assistant-app) --app healthcare-assistant-app
heroku config:set OPENAI_API_KEY='your-api-key-here' -a healthcare-assistant-app
heroku config:set GITHUB_TOKEN='your-github-token-here' -a healthcare-assistant-app
  • Retrieve the set environment variables:
heroku config -a healthcare-assistant-app
  • Push the code to Heroku:
git push heroku main
  • Create a heroku yaml file as in heroku.yml or copy and paste the content below in your heroku.yml file.
setup:
  addons:
    - plan: heroku-postgresql
build:
  docker:
    web: Dockerfile
  • Build the Docker image and push it to Heroku:
heroku container:push web -a healthcare-assistant-app
  • Release the Docker image:
heroku container:release web -a healthcare-assistant-app
  • Check the logs to ensure the application is running correctly:
heroku logs --tail -a healthcare-assistant-app
  • Open the deployed application:
heroku open -a healthcare-assistant-app
  • To restart the application:
heroku restart -a healthcare-assistant-app
  • To remove the deployed container and destroy the Heroku app:
heroku container:rm web -a healthcare-assistant-app
heroku apps
heroku apps:destroy healthcare-assistant-app

Extras

Follow these steps to set up ssh keys to access heroku apps via the command line:

  1. First, check if you already have an SSH key.
ls -al ~/.ssh
  1. Generate a new SSH key with a custom name (let's call it id_ed25519_heroku). Remember to replace "your.email@example.com" with your actual email address when generating the key!
ssh-keygen -t ed25519 -C "your.email@example.com" -f ~/.ssh/id_ed25519_heroku
  1. After generating, start the SSH agent.
eval "$(ssh-agent -s)"
  1. Add your new key to the SSH agent.
ssh-add ~/.ssh/id_ed25519_heroku
  1. View your new public key.
cat ~/.ssh/id_ed25519_heroku.pub
  1. Add it to Heroku.
heroku keys:add ~/.ssh/id_ed25519_heroku.pub
  1. Verify your keys are now listed in your SSH directory.
ls -al ~/.ssh
  1. Check that Heroku recognizes the connection.
ssh -v git@heroku.com
  1. View associated keys.
heroku keys

To learn more about ssh keys and heroku, check out the guide in this link 👉 Heroku SSH keys