-
Create an account or Login:
-
Click on Create a new app:
-
Fill up the form:
-
You are now directed to your app dashboard.
-
Scroll down to Install the Heroku CLI:
-
Go to your Integrated Development Environment (IDE) and open your project.
-
Open the terminal and follow the next steps.
-
Install Heroku by typing:
npm install -g heroku
in the CLI.- npm stand for Node Package Manager.
- -g means that we install the Heroku globally or system-wide.
- It is important to note that if -g is not included, Heroku will only be installed within a directory called “node-modules” and it will not work as we want it to.
-
Login to Heroku in the terminal:
-
On the Heroku platform and on your app dashboard, look for Open app on the top right by scrolling up:
-
Now your Heroku app is running:
- Note that this is the default Heroku app and that you still need to push your project to it.
- Your app's URL corresponds to https://your-app-name.herokuapp.com
- Go to settings on your Heroku dashboard and copy your Heroku Git URL.
- Create another git remote (that will be different from “origin”*):
- Push to Heroku:
- You will get an error message because the requirements file is missing. We will add it in the next step.
- We need to create a requirements.txt file that will list all the Python dependencies the project needs to install in order to run successfully:
- This will provide Heroku a mean to know what language we are using.
- Type in the terminal
pip3 freeze --local > requirements.txt
. This will redirect the output of the freeze command (that list the dependencies) into a file called requirements.txt. - Add, Commit and Push to Heroku remote master as in step 5.:
- Create a Procfile:
- Type in the terminal
echo web: python run.py > Procfile
. - It is important to note that run.py is the name of our python file and Procfile is with a capital P.
- Type in the terminal
- Add, Commit and Push as shown below:
- By reloading a refreshing your app on Heroku or by clicking on
Òpen app
, your app should display now. - Because in this project we use a secret-key variable, we need, for the application to fully function, to add any hidden environment variables, or Config Vars, within our App Settings.
With Automatic Deployment from GitHub, by linking a GitHub repository to Heroku and deploy it automatically.
- From the Deploy section of your app, click on the GitHub Deployment method:
- Click on connect to GitHub and Authorize Heroku to connect.
- Fill up the input for the name of your repository and click search.
- Click connect.
- You need to make sure your project is not connected to Heroku but only to GitHub:
- in the terminal, type
git remote -v
and if it returns more the heroku remote, than remove it with the commandgit remote rm *name-of-your-remote*
- in the terminal, type
- Add and Push your project to GitHub typing in the terminal:
git add .
git commit -m "Push to GitHub."
git push origin master
- Note that here the “main” branch is called “master”. You can check your main branch name in the settings of your repository on GitHub.
- Click on
Deploy Automatically
andDeploy Branch
. - When Deployment successful, you can view the website clicking on
view
orÒpen app
This will give a quick and short reminder on the important steps to deploy the on Heroku.
- Create a Heroku app
- Connect Git remote to Heroku or Set automatic Deployment from GitHub.
- Create a requirements.txt file
- Create a Heroku Procfile: Tells Heroku how to run the project.
You can find the Heroku CLI command on Code-Institute-Solutions/ FlaskFramework