# Use the official NVIDIA CUDA image FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04 # Set environment variables for non-interactive installation and timezone ENV DEBIAN_FRONTEND=noninteractive \ TZ=Europe/Paris # Set the working directory WORKDIR /app # Create a non-root user RUN useradd -m appuser # Install system dependencies and Python RUN apt-get update && apt-get install -y \ python3-pip \ python3-dev \ git \ && rm -rf /var/lib/apt/lists/* # Install any necessary Python packages (e.g., Flask, transformers, torch, etc.) COPY requirements.txt requirements.txt RUN pip3 install --no-cache-dir -r requirements.txt # Create writable directories for Hugging Face and Triton cache RUN mkdir -p /workspace/huggingface_cache /home/appuser/.triton && \ chmod -R 777 /workspace/huggingface_cache /home/appuser/.triton # Set environment variables for Hugging Face and Triton cache ENV HF_HOME=/workspace/huggingface_cache ENV TRITON_CACHE_DIR=/home/appuser/.triton # Set umask to ensure proper file permissions RUN umask 002 # Copy the application code into the image COPY . . # Change ownership to non-root user RUN chown -R appuser:appuser /app /workspace/huggingface_cache /home/appuser/.triton # Switch to non-root user USER appuser # Expose the port your application will run on EXPOSE 7860 # Run the application CMD ["python3", "app.py"]