# Base stage: Install common dependencies FROM python:3.10-slim AS base # Set working directory and environment variables WORKDIR /usr/src/app ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=1 # Copy only requirements files first to leverage Docker cache COPY pyproject.toml ./ # Install system and Python dependencies in a single layer RUN apt-get update && \ apt-get install -y --no-install-recommends \ build-essential \ gcc \ libssl-dev && \ pip install --no-cache-dir --upgrade pip setuptools setuptools-scm && \ rm -rf /var/lib/apt/lists/* # Copy project files COPY . . # Install base project RUN pip install --no-cache-dir -e . CMD ["bash"]