Chapter 9: Deploying FastAPI Applications
In the last chapter, you learned how to write tests for API endpoints created in a FastAPI application. We started by learning what testing means and walked through the basics of unit testing using the pytest
library. We also looked at how to eliminate repetition and reuse test components with fixtures and then proceeded to set up our test environment. We wrapped up the last chapter by writing tests for each endpoint and then testing them alongside checking the test coverage reports after testing.
In this chapter, you’ll learn how to deploy your FastAPI application locally using Docker and docker-compose. A brief section is also added with external resources to deploy your application on serverless platforms of your choice.
In this chapter, we’ll be covering the following topics:
- Preparing for deployment
- Deploying with Docker
- Deploying Docker images