FastAPI with Docker compose
examples/fastapi/Dockerfile
FROM python:3 WORKDIR /opt COPY requirements.txt . RUN pip install -r requirements.txt # COPY . .
examples/fastapi/docker-compose.yml
version: '3' services: app: build: context: . dockerfile: Dockerfile tty: true command: bash volumes: - .:/opt ports: - "8000:8000" mongodb: image: mongo:4.0.8 volumes: - mongo-data:/data/db - mongo-configdb:/data/configdb volumes: mongo-data: mongo-configdb:
examples/fastapi/requirements.txt
fastapi[all] pytest requests motor
docker compose up
docker exec -it fastapi_app_1 bash
uvicorn main:app --reload --host=0.0.0.0