Python: Creating a Makefile for Stackhero deployment
This documentation is part of the Deploy to production guide. View the full 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 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 will use a Makefile in your project's root directory.
If you are new to
Makefilefiles and themakecommand, that is okay. 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 -
There are a few things to keep in mind with 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. Be sure to adjust it to fit 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 app (make sure it is listed 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, you will also need to update your Python service configuration in the Stackhero dashboard. The app:app part refers to the app object inside your app.py file.