Week 3: Let’s Make It Public!
March 27, 2023
Hi everyone!
Last week I created a minimalist version of the ScrapSaver website and was able to run the program locally on my computer. This week, I’m pushing that basic website onto the cloud so anybody can access it!
I chose to use Heroku as my cloud platform for a few reasons: simplicity and versatility. Compared to other hosting services, Heroku is (1) free for beginner users, (2) extremely straightforward to connect, and (3) has GitHub compatibility. Additionally, it offers a service to host my PostgreSQL database, so it made sense to use one company for both hosting and database management. In this post, I’ll explain how I connected my website to the Heroku cloud.
Step 1: Downloading Heroku Command Line Interface (CLI)
Step 2: Installing dependencies
Step 3: Configuring Heroku
Step 4: Deploy to GitHub
Step 1: The first step was to download the Heroku CLI so I could directly interact with Heroku through my computer’s terminal instead of using Heroku’s buttons. In general, it’s better practice to work through one consolidated terminal so that all aspects of the project can be traced through one medium.
After installing the Heroku CLI, I was able to create and log into my Heroku account through terminal rather than Heroku’s UI. I was also able to create a connection between Heroku and my GitHub account for future configurations.
Step 2: The second step was to install all the dependencies my project would need and make them readable for Heroku.
I used Pip Install Packages (pip) to install the following dependencies: django, django-filter, django-storages, boto3, pillow, gunicorn, whitenoise. I learned about these dependencies through django’s website. Then, I put all these dependencies into a requirements.txt file, which tells Heroku all the packages that Heroku requires.
Step 3: The third step is to configure Heroku with my local website
pip freeze >> requirements.txt
This created a file that had all the packages and the specific versions of each:
I created a runtime.txt file, which tells Heroku which version of python I’m using. Additionally, I created a Procfile, which declares what commands are run by my project:
Then, I needed to connect the actual url of my new Heroku website to my django project:
Step 4: The last step is to connect the website to my GitHub. Whenever I modify ScrapSaver, I’ll always test it locally and only push to GitHub when it works. The local website is for testing, while the public website should always work.
This time, I used Heroku’s UI to connect; I clicked the connect button, and specify which branch I’d be using. After connecting and troubleshooting a few errors,
ScrapSaver is now public: https://ssaver.herokuapp.com/login/?next=/
See you guys next week, when I’ll connect to the Heroku database!