Spaces:
Paused
Paused
# Use NVIDIA CUDA image as the parent image | |
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04 | |
# Set the working directory inside the container | |
WORKDIR /app | |
# Create a non-root user | |
RUN useradd -m appuser | |
# Set noninteractive mode to skip prompts | |
ENV DEBIAN_FRONTEND=noninteractive | |
# Install Python and pip | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
python3 \ | |
python3-pip \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Copy the requirements file into the container at /app | |
COPY ./requirements.txt /app/ | |
# Grant necessary permissions to the non-root user | |
RUN chown -R appuser /app | |
# Switch to the non-root user | |
USER appuser | |
# Install Python dependencies and add necessary directories to PATH | |
RUN python3 -m pip install --user --no-cache-dir --upgrade pip && \ | |
python3 -m pip install --user --no-cache-dir -r requirements.txt uvicorn && \ | |
hash -r | |
# Add necessary directories to PATH | |
ENV PATH="/home/appuser/.local/bin:${PATH}" | |
# Explicitly add the scripts directory to PATH | |
ENV PATH="/home/appuser/.local/bin:/home/appuser/.local/scripts:${PATH}" | |
# Copy the current directory contents into the container at /app | |
COPY . /app/ | |
# Create a writable cache directory inside the /app directory | |
RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache | |
# Specify the command to run your application | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |