Docker Setup
The project is fully containerized to ensure consistent behavior across development and production environments. We use Docker for the application runtime and Docker Compose for orchestration.
Dockerfile Overview
The Dockerfile uses a multi-stage build to minimize image size.
-
Builder Stage:
- Base:
python:3.12-slim-bookworm - Tooling: Installs
uvfor fast package management. - Action: Compiles dependencies into a virtual environment in
/opt/venv.
- Base:
-
Runtime Stage:
- Base:
python:3.12-slim-bookworm - System Deps: Installs runtime libraries like
libgl1(for OpenCV). - Setup: Copies the pre-built venv, creates a non-root user
appuser, and sets up the entrypoint.
- Base:
Docker Compose
The docker-compose.yml orchestrates the services:
- live-app: The main FastAPI application.
- Ports: Maps internal
8000to host8000. - Volumes: Mounts
src,data,staticas read-only for hot-reloading (in dev). - Environment: Loads from
.env.
- Ports: Maps internal
- docs: A local documentation server (Perlite) for viewing this Obsidian vault.
- nginx: Reverse proxy for the documentation.
Commands
Build and Run
docker compose up --buildThis will start:
- Web App at
http://localhost:8000 - Documentation at
http://localhost:8080(if enabled)
Stop
docker compose down