Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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
titleDockerfile Preview
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"]

Build a Docker Image for SearchA PI

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:

  • Using Kubernetes or similar tools
  • When running on a Raspberry Pi
  • Using a cloud service that would run a container image for you, etc.

Package Requirements

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