7.1. Docker

7.1.1. Requirements

  • requirements.txt

Minimal Setup:

fastapi
uvicorn

Full Stack:

fastapi
pydantic
pydantic[email]
sqlalchemy
uvicorn[standard]
passlib[bcrypt]
python-jose[cryptography]
python-multipart

7.1.2. Official Image

  • Dockerfile

FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8-alpine3.10
COPY . /app/

7.1.3. Custom Image

  • Dockerfile

FROM alpine
COPY . /app
WORKDIR /app
EXPOSE 8000/tcp

RUN apk add --no-cache python3 py3-pip \
 && pip install --no-cache-dir -r /app/requirements.txt

CMD uvicorn main:app --host 0.0.0.0 --port 8000