Deploying a model using containers
Before you can containerize your application, you need to ensure it runs properly in a production environment. Then, you can build a Dockerfile, a configuration file that reproduces that production environment as a container. You’ll complete both the testing and containerization steps on your local system; then, in the next section, you’ll learn how to deploy your container to the cloud.
Let’s consider an example Dockerfile that includes the pieces you’d need to containerize the Flask API you created earlier in this chapter and the model from Chapter 9:
- First, you’ll need to inherit Python from a standardized image. You’ll want to match the version to what you’ve been using – in this case, Python 3.9. The
-slim
option reduces the amount of disk space your container takes up:FROM python:3.9-slim
- Next, you’ll want to establish a web socket so that it uses
EXPOSE 8000
, as well...