Python: Creating a Makefile for Stackhero deployment

This documentation is part of the Deploy to production guide. You can view the complete guide here: How to deploy your Python code to production in just a few minutes.

👋 Welcome to the Stackhero documentation!

Stackhero offers a ready-to-use Python cloud solution that provides a host of benefits, including:

  • Deploy your application in seconds with a simple git push.
  • Use your own domain name and benefit from the automatic configuration of HTTPS certificates for enhanced security.
  • Enjoy peace of mind with automatic backups, one-click updates, and straightforward, transparent, and predictable pricing.
  • Get optimal performance and robust security thanks to a private and dedicated VM.

Save time and simplify your life: it only takes 5 minutes to try Stackhero's Python cloud hosting solution!

To tell Stackhero how to run your application, you’ll use a Makefile at the root of your project.

If you’re new to Makefile files and the make command, don’t worry. Just follow these instructions to get started.

Create a Makefile at the root of your project with the following content:

run:
	gunicorn app:app -b 0.0.0.0:8080 --error-logfile -

A few important points about this Makefile:

  1. The run rule is required, as Stackhero executes it automatically. Please do not rename it.
  2. The command gunicorn app:app -b 0.0.0.0:8080 --error-logfile - is just an example. Adjust it to suit your application’s requirements.
  3. Make sure to start the gunicorn command with a tab character. If you see an error like "*** missing separator", it means the tab is missing.

In this example, Gunicorn is used to serve your application (make sure it is listed in your requirements.txt). The argument -b 0.0.0.0:8080 means it listens on all interfaces on port 8080. If you choose a different port, remember to update your Python service configuration in the Stackhero dashboard. The app:app part refers to the app object inside your app.py file.