Python: Creating a Makefile for Stackhero deployment

This documentation is part of the Production deployment guide. You can view the complete guide here: How to deploy your Python code to production in minutes.

👋 Welcome to the Stackhero documentation!

Stackhero offers a ready-to-use Python cloud solution designed to simplify your deployments:

  • Deploy your application to production within seconds using a simple git push.
  • Use your own domain name, with automatic HTTPS certificate setup for secure connections managed on your behalf.
  • Take advantage of automatic backups, one-click updates, and predictable pricing, so you can focus on your code rather than infrastructure management.
  • Benefit from high performance and security on a private, dedicated infrastructure. Your environment is isolated and protected.

Save time and streamline your workflow: your code can be up and running with Stackhero's Python cloud hosting in just 5 minutes.

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

If you are new to Makefile files and the make command, do not worry. Simply 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 regarding this Makefile:

  1. The run rule is mandatory, 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 needs.
  3. Make sure to start the gunicorn command with a tab character. If you see an error such as "*** missing separator", it means the tab is missing.

In this example, Gunicorn is used to serve your application (ensure it is included in your requirements.txt). The argument -b 0.0.0.0:8080 means it listens on all interfaces at 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 in your app.py file.