Skip to content

Installation: Linux: Heroku

Faiz-ur Rahman edited this page Apr 30, 2021 · 2 revisions

Prerequisite Steps

  1. Fork this repo
  2. Create a new Heroku app from your Heroku dashboard (Create new app)
  3. After creation go to the Deploy tab and under Deployment method connect to the forked repo you created in step 1.
    1. After it's connected it'll look like this.

Local Testing

  1. Download your forked repo and run npm install
  2. Set up the dotenv file to your liking
    1. IMPORTANT OPEN_BROWSER needs to be set to false in the dotenv file, otherwise it will error when running on Heroku
  3. Run the app with npm run start and verify everything is working to your liking

Heroku Preparations

  1. Create a Procfile in the root directory of the project and add the following line:
    worker: npm run start:production

    1. We use worker or else Heroku will timeout by attempting to bind to a port. Also notice we're using the start:production target. When you push to Heroku, your code is already compiled by tsc.
  2. Remove build/ and dotenv from the .gitignore file

    1. If you didn't test locally in the previous section, make sure to run npm run start at least once so that your build/ folder is created.
  3. Update puppeteer args in the main function in index.ts

    const args: string[] = [
      '--no-sandbox',
      '--disable-setuid-sandbox'
    ];
  4. Commit all these changes to the forked repo

  5. Add the puppeteer and nodejs buildpacks in settings in your Heroku dashboard

    1. Manually add https://github.com/jontewks/puppeteer-heroku-buildpack to the "buildpacks" list
    2. Add nodejs from the prepopulated choices
    3. It should look like this afterwards

Heroku deploy

  1. In the deploy tab of your Heroku project, scroll down to Manual deploy, and click Deploy Branch
  2. Wait for the build to finish deploying
  3. Click More (top right of the screen) > View Logs
    1. CONGRATS! You should now see the same output as you would if you were running this app locally