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.
- A Heroku account
- Heroku CLI installed in terminal
- Go to Heroku and sign up for an account.
- Verify your email address and log in to your account.
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.
- 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
Follow these steps to set up ssh keys to access heroku apps via the command line:
- First, check if you already have an SSH key.
ls -al ~/.ssh
- 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
- After generating, start the SSH agent.
eval "$(ssh-agent -s)"
- Add your new key to the SSH agent.
ssh-add ~/.ssh/id_ed25519_heroku
- View your new public key.
cat ~/.ssh/id_ed25519_heroku.pub
- Add it to Heroku.
heroku keys:add ~/.ssh/id_ed25519_heroku.pub
- Verify your keys are now listed in your SSH directory.
ls -al ~/.ssh
- Check that Heroku recognizes the connection.
ssh -v git@heroku.com
- View associated keys.
heroku keys
To learn more about ssh keys and heroku, check out the guide in this link 👉 Heroku SSH keys