# Use an official Python runtime as a parent image FROM python:3.10-slim # Set the working directory in the container WORKDIR /code # --- FINAL FIX: Install system-level build tools --- # The 'slim' python image is minimal. Libraries like bitsandbytes and peft # need a C compiler (gcc) and other tools to build custom CUDA kernels. # 'build-essential' installs these required tools via the system package manager. RUN apt-get update && apt-get install -y build-essential # Create a writeable directory for caching models and other artifacts. RUN mkdir -p /code/data/.cache && \ chmod -R 777 /code/data # Redirect all cache directories to our writeable location. ENV HF_HOME="/code/data/.cache" ENV TRITON_CACHE_DIR="/code/data/.triton" # Copy and install all required python libraries COPY ./requirements.txt /code/requirements.txt RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt # Copy the main application file COPY ./app.py /code/app.py # Command to run the app CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]