- Heroku Cookbook
- Mike Coutermarsh
- 693字
- 2021-08-05 17:14:26
Installing the Heroku Toolbelt
Heroku applications are created and administered from the command line. To get started with Heroku, we need to install the Heroku Toolbelt. It contains everything we need to create and deploy new applications.
The toolbelt is an installer for three command-line tools:
- Heroku Command Line Interface (CLI): This is an interface to the Heroku Platform API
- Git: This is used for version control and to deploy our applications
- Foreman: This is a tool to run Procfile-based applications
In this recipe, we will install the Heroku Toolbelt, making sure our machine is set up to use the Heroku CLI. We'll also be briefly introduced to the Heroku CLI. We'll learn about Git and Foreman later in the chapter.
Note
If you already have the Heroku Toolbelt, it might be beneficial to go through the following steps again to ensure that the latest version is installed.
Getting ready
First, we need to create a Heroku account with the following steps:
- Let's go to an account if we do not already have one.
Note
Remember to use a strong and unique password for Heroku. This account will be able to access our source code and data, so treat it like any other sensitive set of credentials.
- Next, let's install the Heroku Toolbelt. Specific download and installation instructions are available at https://toolbelt.heroku.com/ for Mac, Windows, and Linux.
Note
Throughout this book, we will be using a
$
sign to indicate that a command should be run in a terminal. The$
sign is not part of the command. - Once the Heroku Toolbelt is installed, we can verify that everything is working by opening up a terminal and running the following command:
$ heroku --version heroku-toolbelt/3.11.1 (x86_64-darwin10.8.0) ruby/1.9.3
We should see the version of the Heroku Toolbelt we are using printed to the console.
How to do it...
Now that we have the Heroku Toolbelt installed, let's log in to our account via the CLI and authorize our computer by uploading our public key using the following steps:
- Let's log in by opening up a terminal and running the following command:
$ heroku login Username: youremail@example.com Password (typing will be hidden): Could not find an existing public key.Would you like to generate one? [Yn]Generating new SSH public key.Uploading ssh public key /Users/mc/.ssh/id_rsa.pub
If we do not have an existing public key, the Heroku CLI will provide us with instructions on how to create one here. This key will be uploaded to Heroku's servers and used for authentication whenever we push new code to our applications.
Note
We'll need to repeat this step for any other computers we use Heroku from.
- We can ensure that we are authenticated with the
auth:whoami
command. If logged in successfully, it will print our e-mail address:$ heroku auth:whoami youremail@example.com
- Finally, we should go to the Heroku dashboard and verify our account by adding a credit card. Having a verified account will allow us to scale our applications and install add-ons (https://dashboard.heroku.com/account).
How it works…
The Heroku Toolbelt installs all the necessary tools to create and administer our Heroku applications. It's essential for us to become comfortable with Heroku's command-line tools. Even though many tasks can be completed on Heroku's website, not everything is available through the dashboard. For full control over our applications, we have to use the CLI.
Authentication
Ever wondered how Heroku keeps us logged in to the CLI? During the login process, Heroku stores an API key for our account in our .netrc
file. The .netrc
file is a dotfile that lives in our home directory. It's a common file that applications use to store credentials to log in to remote hosts. The API key stored in this file is used for subsequent logins and keeps us logged in to our Heroku account. If we open our .netrc
file, we'll see an entry for deletes the entry from our .netrc
file, thus logging us out.
Note
We do not need to worry about updating Heroku Toolbelt; it will automatically check for updates for us.
See also
- Interested in seeing the source code for the Heroku CLI? It's open source; take a look at https://github.com/heroku/heroku.
- 數據科學實戰手冊(R+Python)
- Learning Cython Programming
- ThinkPHP 5實戰
- Learning ASP.NET Core 2.0
- Flask Web開發入門、進階與實戰
- Unity Virtual Reality Projects
- Linux網絡程序設計:基于龍芯平臺
- Effective Python Penetration Testing
- GeoServer Beginner's Guide(Second Edition)
- C語言實驗指導及習題解析
- Unity UI Cookbook
- Spring Boot+MVC實戰指南
- Web前端開發技術:HTML、CSS、JavaScript
- 分布式數據庫HBase案例教程
- Learning D3.js 5 Mapping(Second Edition)