Before we are able to deploy on Heroku you need to make sure you have a few things installed. We will go through those requirements here to ensure you are ready to deploy in just a few simple steps.
The first thing we need to do is make sure you have a Heroku account created. This will give you access to Heroku’s deployment services and will allow you to manage your deployed applications on their web app. It is free to sign up so visit the Heroku homepage and sign up for an account.
The next thing you should do is install the Heroku Toolbelt. The toolbelt is a command line tool that will expand the functionality of your command line to include
heroku commands. For example, once installed you will be able to use the
heroku login command to log into your account from your command shell. To install the Heroku Toolbelt navigate to toolbelt.heroku.com and follow the installation instructions for your operating system.
Once you have your Heroku account and the toolbelt installed you will want to log in to your Heroku account from the command line. To do this, open up your command line shell and type
heroku login. This will prompt you for your Heroku email and password. If you entered your information correctly, your command line output should look something like the image below. You won’t have to log in every time you want to deploy, your credentials will be saved for some time, so this is a good command to keep in mind if you get logged out at some point.
Heroku deploys the most recent version of your app by keeping track of changes via Git. Make sure that you have Git installed on your command shell. If you do not have Git installed you can visit this link to get yourself set up. Most recent MacOS machines come with Git already installed, and if you have been building applications on your development environment already, it is likely you have already been using Git.
Clone Repository Now that you have everything you need to get started, you will need to clone the gallery application you are going to deploy. Open up your command line and navigate to the location where you want the repository to live, this is often a projects directory but it can be anywhere you like on your machine as long as it is not within another Git repository. If you are not sure if there is a git repo on your working directory you can check using
git status. If you get a message saying
fatal: Not a git repository (or any of the parent directories): .git This means you are not in a Git repo and you can clone in this location. Go to the Udacity repository in your web browser.
In order to make updates to the codebase, you will need your own copy of the repository, which you can do from the Github page. You will need an account on Github in order to fork the repository to your own account. Click the ‘fork’ button in the upper right corner of the page (see image above) and choose your account to fork.
Once you have forked the repository, open your new repository in your web browser and copy the clone URL. Return to your command line and type
git clone followed by the git clone URL you just copied. This will clone the code on GitHub to your computer.
Once you have installed all the tools and cloned the repo, you are ready to go live. Let’s go ahead and change our working directory to the repository directory:
It is generally a good idea to check your
git status to make sure you are about to deploy the most updated stable version. Let’s deploy!
To get yourself deployed on Heroku, you must first create a remote on Git. To do this you have to run the
heroku createcommand. This will make a new remote repo named
heroku where the code will be pushed to.
To ensure you have properly created this remote, run the
git remote -v command, you should see something output that reveals the two remotes listed,
Git Push Heroku Master
Now the last step, the ribbon cutting is the command
git push heroku master. This command is very similar to the
git push that you may be familiar with when pushing your code to GitHub. Instead of pushing it to github via the
originremote, you are pushing it to the
From this point you will see a large output from Heroku that is listing all of the libraries and tools that are being installed on the Heroku machine before your code is finally decompressed and launched onto the online server.
Once you have your application deployed, Heroku will provide you with a URL you can visit to see your site. After this you can run
heroku open. This will open up a browser window and navigate to the deployed application URL.
Now your gallery is live! Click on the “New Art Piece” button to see a new image appear!