Goal: Wrap your capstone's core service in FastAPI, containerize it with a secure multi-stage Dockerfile using uv, and bring up your full local stack — API plus datastore — with a single docker compose up command. Everything in this lab runs locally and is free. Steps:
/predict (or equivalent) endpoint and a /health endpoint. Follow the official FastAPI in Containers guide for the recommended app layout.pyproject.toml for your service and run uv lock to generate a uv.lock. Commit both files — the lockfile is what makes your container reproducible.builder stage on a pinned base image (e.g. python:3.12-slim, never :latest) that copies in pyproject.toml + uv.lock and runs uv sync --frozen. Use a second, minimal runtime stage that copies only the installed environment and your application code from the builder stage — no compilers, no source of unrelated tooling. Reference the Docker Python containerization guide and the Machine Learning Mastery FastAPI + Docker guide for structure.RUN useradd -m appuser) and add USER appuser before your CMD. Confirm your CMD launches Uvicorn on 0.0.0.0 at a fixed port. Never bake secrets or environment-specific config into the image.docker-compose.yml alongside your API service.environment: or an env_file: — never hardcoded into the Dockerfile — and add a named volume for the datastore so data survives restarts. Use the Docker multi-stage builds reference if you need a refresher on stage syntax, or Docker 101 if you want a broader Docker refresher first.docker compose up from a clean checkout and confirm both containers start, the API container is running as a non-root user (docker exec <container> whoami), and your /predict endpoint returns a correct response when called against the running stack (e.g. via curl or FastAPI's interactive docs at /docs).docker images) and briefly describe what you removed from the runtime stage compared to a naive single-stage build.Deliverables: Your Dockerfile, docker-compose.yml, pyproject.toml, and uv.lock, submitted as an upload (zipped project folder or repo link) plus a short text entry confirming docker compose up successfully launches your containerized core service with a working /predict endpoint, including your final image size and non-root user confirmation.