When deploying FastAPI applications a common approach is to build a Linux container image. It's normally done using Docker. You can then deploy that container image in one of a few possible ways.
Using Linux containers has several advantages including security, replicability, simplicity, and others.
Tip |
---|
In a hurry and already know this stuff? Jump to the Dockerfile below. |
Code Block | ||
---|---|---|
| ||
FROM python:3.9 WORKDIR /code COPY ./requirements.txt /code/requirements.txt RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt COPY ./app /code/app CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"] # If running behind a proxy like Nginx or Traefik add --proxy-headers # CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80", "--proxy-headers"] |
This section will show you how to build a Docker image for Search API from scratch, based on the official Python image.
This is what you would want to do in most cases, for example:
Install the Search API requirements the same way it is specified in Install Python Dependencies
But in essence you need to do this
Code Block |
---|
pip install -e . |
And then
Infocode |
---|
pip install lib/pyqpl-VERSION_IN_PROJECT-py3-none-any.whl |