File size: 1,349 Bytes
08d6535 1a8807d 12da5b1 0577dcd c30c902 0577dcd 08d6535 1a8807d 08d6535 0577dcd 1a8807d ce10a1f 0577dcd 08d6535 0577dcd ce10a1f 08d6535 ce10a1f 1a8807d 08d6535 0577dcd 08d6535 12da5b1 08d6535 ce10a1f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# Use the NVIDIA CUDA image as the base
FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu20.04
# Set non-interactive mode for apt-get
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
cmake \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user
# Set the working directory
WORKDIR /app
# Create and activate virtual environment
RUN python3.10 -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
# Copy the requirements file
COPY requirements.txt .
# Install Python dependencies
RUN . /app/venv/bin/activate && \
pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Install llama-cpp-python with CUDA support
RUN . /app/venv/bin/activate && \
pip install llama-cpp-python \
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu121
# Copy the rest of the application code
COPY . .
# Change ownership of the app directory to the user
RUN chown -R user:user /app
# Switch to the "user" user
USER user
# Set the PATH to include the user's local bin directory
ENV PATH="/home/user/.local/bin:$PATH"
# Run the application
CMD ["/app/venv/bin/uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |