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 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’ll use a Makefile at the root of your project.
If you’re new to
Makefilefiles and themakecommand, 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:
- The
runrule is required, as Stackhero executes it automatically. Please do not rename it. - 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. - 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.