Configure the Production Server
Explore the essential steps to configure a production server for a full stack web application. Learn to manage dependencies with Pipfile lock, set up Python and NGINX buildpacks on Heroku, and deploy using Gunicorn as a WSGI server. Understand the role of NGINX as a reverse proxy to efficiently serve static files and handle HTTP requests, ensuring your Flask application runs smoothly in production.
We'll cover the following...
Locking Pipfile
The first step to preparing the production server is making sure it has everything it needs. We’ve already discussed the database dependency separately, but the server also requires a number of Python packages, such as SQLAlchemy, as well as the packages SQLAlchemy requires, and so on. Heroku makes life easier by grabbing the right versions of each dependency from the Pipfile.lock file in our repositories and then finding all the packages we’ll need. Generally, the lock file stays up-to-date since it re-locks every time we install or uninstall a package. We can double-check that the lock file is up-to-date by running the following:
$ pipenv lock
Locking [dev-packages] dependencies
✓ Success!
Locking [packages] dependencies
✓ Success!
Updated Pipfile.lock (7dc556)!
Python addon
The application uses Python and, in general, Heroku does a good job of identifying a Python environment by finding the Pipfile. However, we will ...