Skip to main content
Checawaa can be easily deployed to Heroku using the included Procfile and configuration. This guide walks you through the deployment process.

Prerequisites

Before deploying, ensure you have:

Deployment Steps

1

Login to Heroku

Open your terminal and authenticate with Heroku:
heroku login
This will open a browser window for you to complete the authentication.
2

Create a Heroku App

Create a new Heroku application:
heroku create your-app-name
Replace your-app-name with your desired application name. If you omit the name, Heroku will generate a random one.
3

Configure Environment Variables

Set up the required environment variables for your application:
heroku config:set SECRET_KEY=your_secret_key_here
heroku config:set MAIL_SERVER=smtp.gmail.com
heroku config:set MAIL_PORT=587
heroku config:set MAIL_USE_TLS=True
heroku config:set [email protected]
heroku config:set MAIL_PASSWORD=your_app_password
Never commit sensitive credentials to your repository. Always use environment variables for production deployments.
For Gmail, you’ll need to generate an App Password instead of using your regular password.
4

Deploy the Application

Push your code to Heroku:
git push heroku main
If your default branch is named master instead of main, use git push heroku master.
Heroku will automatically detect the Python application, install dependencies from requirements.txt, and start the app using the Procfile configuration.
5

Scale the Web Dyno

Ensure at least one web dyno is running:
heroku ps:scale web=1
6

Open Your Application

Launch your deployed application in the browser:
heroku open

Understanding the Procfile

The application includes a Procfile that tells Heroku how to run your app:
Procfile
web: gunicorn app:app
This configuration:
  • Defines a web process type
  • Uses Gunicorn as the WSGI HTTP server (production-ready)
  • Points to the Flask application instance (app:app refers to the app variable in app.py)
Gunicorn is specifically designed for production environments and handles multiple concurrent requests efficiently, making it ideal for Heroku deployments.

Post-Deployment Configuration

Setting Up the Scheduler

The application uses APScheduler to send automated reminders at 8:00 AM. In production on Heroku, you may need to consider timezone settings:
heroku config:set TZ=America/Mexico_City
Replace America/Mexico_City with your appropriate timezone. The scheduler is configured in app.py:88-91 to trigger at 8:00 AM local time.

Data Persistence

The application stores data in JSON files in the data/ directory. For production use, consider:
Heroku’s filesystem is ephemeral. Files written to the dyno will be lost when the dyno restarts. For persistent storage, consider:
  • Using a database addon (PostgreSQL, MongoDB)
  • Implementing cloud storage (AWS S3, Google Cloud Storage)
  • Using Heroku’s Redis or other persistence solutions

Monitoring and Logs

View Application Logs

Monitor your application in real-time:
heroku logs --tail

Check Dyno Status

Verify your application is running:
heroku ps

Troubleshooting

Application Crashes

Check the logs for errors:
heroku logs --tail
Common issues:
  • Missing environment variables
  • Incorrect Python version
  • Missing dependencies in requirements.txt

Scheduler Not Running

The APScheduler may not work correctly on Heroku’s free dynos due to sleeping. Consider:
  • Upgrading to a paid dyno
  • Using Heroku Scheduler addon
  • Implementing a webhook-based solution

Email Sending Fails

Verify your email configuration:
heroku config
Ensure:
  • MAIL_USERNAME and MAIL_PASSWORD are correct
  • You’re using a Gmail App Password (not regular password)
  • Two-factor authentication is enabled on your Gmail account

Updating Your Deployment

When you make changes to your application:
git add .
git commit -m "Your commit message"
git push heroku main
Heroku will automatically rebuild and redeploy your application.

Additional Resources

Build docs developers (and LLMs) love