# Use the NVIDIA CUDA image as the base FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu20.04 # Set up a new user named "user" with user ID 1000 RUN useradd -m -u 1000 user # Switch to the "user" user USER user # Set home to the user's home directory ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Set the working directory to the user's home directory WORKDIR /app # Install Python and pip RUN apt-get update && apt-get install -y python3 python3-pip # Install CMake and other build dependencies RUN apt-get install -y cmake build-essential # Install llama-cpp-python with CUDA support ENV FORCE_CMAKE=1 ENV CMAKE_ARGS="-DLLAMA_CUBLAS=on" RUN pip install llama-cpp-python --no-cache-dir # Copy the current directory contents into the container at /app COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of the application code COPY --chown=user . /app # Run the application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]