FROM python:3.11-slim WORKDIR /app # Install system deps for MNE/scipy RUN apt-get update && apt-get install -y --no-install-recommends \ gcc g++ && \ rm -rf /var/lib/apt/lists/* COPY requirements.txt . # Install CPU-only PyTorch first (saves ~1.5GB vs full torch) RUN pip install --no-cache-dir torch==2.4.0 --index-url https://download.pytorch.org/whl/cpu # Install remaining deps RUN pip install --no-cache-dir -r requirements.txt COPY . . # Train model if weights don't exist RUN if [ ! -f model_weights.pt ]; then python train.py --epochs 100 --n_synthetic 5000 --output model_weights.pt; fi EXPOSE 7860 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]