Deploying to Heroku

This guide will walk you through deploying TeraCMS to Heroku using GitHub integration for automatic deployments.

Prerequisites

Before you begin, make sure you have:

1. Create a Heroku App

First, create a new Heroku application:

  1. Log in to your Heroku Dashboard
  2. Click New → Create new app
  3. Enter a unique app name (e.g., your-app-name)
  4. Select a location (choose the one closest to your users)
  5. Click Create app

2. Connect GitHub Repository

In the deployment tab (second step after creating the app), select GitHub and connect your repository:

  1. In your Heroku app dashboard, go to the Deploy tab
  2. Under Deployment method, select GitHub
  3. Click Connect to GitHub and authorize Heroku to access your GitHub account
  4. Search for your repository and click Connect
  5. Optionally, enable Automatic deploys from your main branch
  6. Click Deploy Branch to trigger your first deployment

3. Configure Environment Variables

Set up all required environment variables in Heroku:

  1. In your Heroku app dashboard, go to Settings
  2. Click Reveal Config Vars
  3. Add all the environment variables from your .env file, including:

    Required Environment Variables

    Application

    • APP_NAME - Your application name
    • APP_ENV - Set to your environment name (e.g., development or production)
    • APP_KEY - Generate with php artisan key:generate
    • APP_DEBUG - Set to true if you want to see detailed error messages. Set to false for production.

    Database

    • DB_CONNECTION - Set to pgsql for Heroku Postgres
    • DB_HOST, DB_DATABASE, DB_USERNAME, DB_PASSWORD - You can get this from your Heroku Postgres addon settings (explained in the next section) or your database provider.

    Add rest of the environment variables as required by your application from your .env file.

4. Configure Database

Using Heroku Postgres (Paid)

  1. In your Heroku app dashboard, go to the Resources tab
  2. In the Add-ons section, search for Heroku Postgres
  3. Select the plan
  4. Click Submit Order Form

Using your sqlite database

If you are using a sqlite database, remove all the DB values from your config variables. You also need to remove .gitignore file from the database folder. This is not recommended for production environments.

5. Add Node.js Buildpack

  1. In your Heroku app dashboard, go to the Settings tab
  2. Click Buildpacks
  3. Click Add buildpack
  4. Select nodejs from the list
  5. Click Save
  6. Redploy your application manually from the deployment tab

You're app should be deployed successfully now. You can verify by clicking on "Open App" button at the top of your dashboard.

Understanding the Procfile

The Procfile in your project root tells Heroku how to run your application:

web: vendor/bin/heroku-php-apache2 public/
worker: php artisan queue:work --sleep=1 --tries=3 --timeout=90

This Procfile defines two process types:

  • web: Runs your Laravel application using Apache and PHP. This handles HTTP requests.
  • worker: Runs Laravel's queue worker to process background jobs (AI processing, etc.).

Note: The worker dyno is optional but required if you use AI processing due to the long running nature of the jobs.

Enable Worker Dyno

If your application uses AI processing, enable the worker dyno:

  1. Go to the Overv tab
  2. In Dyno Formations section, click "configure Dynos"
  3. Click the pencil icon to edit
  4. Toggle it On and click Confirm