Dockerfile
File Path: Dockerfile
Purpose: Multi-stage build configuration for creating a lightweight production image.
Build Stages
Stage 1: builder
- Base Image:
python:3.12-slim-bookworm - Tools: Installs
uvfor ultra-fast dependency management. - Action:
- Sets up virtual environment at
/opt/venv. - Syncs dependencies from
uv.lockandpyproject.toml. - Uses
--no-install-projectto keep layer small (code is mounted or copied later).
- Sets up virtual environment at
Stage 2: runtime
- Base Image:
python:3.12-slim-bookworm - System Deps:
libgl1,libglib2.0-0: Required for OpenCV (cv2).
- Setup:
- Copies
/opt/venvfrom builder. - Sets environment variables (
PATH,PYTHONPATH, OpenMP threads). - Creates non-root user
appuser(UID 1000).
- Copies
- Entrypoint:
python src/api/run.py
Environment Variables
| Variable | Value | Purpose |
|---|---|---|
UV_COMPILE_BYTECODE | 1 | Faster startup |
OMP_NUM_THREADS | 1 | Prevents CPU contention in container |
PYTHONPATH | /app/src | Allows importing modules from src |
Usage
# Build
docker build -t arsl-app .
# Run
docker run -p 8000:8000 arsl-appRelated Documentation
Driven By:
- pyproject.toml - Dependency definitions
- docker-compose.yml - Orchestration