Heroku Setup Guide for Gather Projects

Hello Everyone!

One of the best ways to host Gather projects on a server for free (or really affordably) is to do so on Heroku. I’ve heard lots of questions during office hours with @opalrose and she asked me to write up a post that would help to explain the process. :smiley:

Here is my attempt to provide some basic steps to get your code hosted and running on Heroku:

  1. Create a new app on Heroku by clicking on the “New” button dropdown in the top right corner

  2. Name your app and click “Create app”

  3. Click on the “Deploy” tab and choose your “Deployment method”

  4. In this guide, I’m choosing Github
    a. If you don’t have a Git repository setup yet, then navigate to www.github.com and create one
    i. Upload your files
    1) Make sure you’ve specified your API_KEY, SPACE_ID, and MAP_ID in your config
    ii. Be sure to include express in your package.json
    iii. Here’s a helpful doc on installing express and what to include: How to deploy your app to the web using Express.js and Heroku
    iv. TLDR express code required:
    const express = require(“express”);
    const app = express();
    // use alternate localhost and the port Heroku assigns to $PORT
    const host = ‘0.0.0.0’;
    const port = process.env.PORT || 3000;

     	app.listen(port, host, function() {
     	  console.log("Server started.......");
     	});
    
  5. Search for your GitHub Repo in the “Connect to GitHub” section and click “Connect”

  6. Choose to “Enable Automatic Deploys” or just go ahead and “Deploy Branch”
    Click on “More” => “View Logs” to watch everything spin up successfully!

Good luck and hope it helps! Looking forward to seeing all of the cool projects you serve on Heroku! :+1:

2 Likes

Great writeup Kevin.

You can also avoid the use of express by setting the heroku dyno to a worker dyno, instead of a web dyno. The worker dynos run 100% of the time, so if you have limited processing time on the server (ie a pay-as-you-go setup), this might not be ideal. However, there is at least 1000 hours of free dyno time a month that users can access, which would allow you to deploy at least 1 extension for free for the month.

Ill come back and add more detail this evening.

3 Likes