# FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04 # ENV DEBIAN_FRONTEND=noninteractive # # Install system dependencies # RUN apt-get update && apt-get install -y \ # python3 python3-pip git \ # ffmpeg libsm6 libxext6 \ # --no-install-recommends \ # && apt-get clean \ # && rm -rf /var/lib/apt/lists/* # # Create a working directory # WORKDIR /app # # Copy requirements and install dependencies # COPY requirements.txt . # RUN pip3 install --no-cache-dir -r requirements.txt # # Copy the application code # COPY app.py . # # Set environment variables # ENV PYTHONUNBUFFERED=1 # ENV GRADIO_SERVER_NAME=0.0.0.0 # ENV GRADIO_SERVER_PORT=7860 # # Expose the port # EXPOSE 7860 # # Command to run the application # CMD ["python3", "app.py"] FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04 ENV DEBIAN_FRONTEND=noninteractive # Install system dependencies RUN apt-get update && apt-get install -y \ python3 python3-pip git \ ffmpeg libsm6 libxext6 \ --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Create a non-root user RUN useradd -m -u 1000 user # Create a working directory WORKDIR /app # Copy requirements and install dependencies COPY requirements.txt . RUN pip3 install --no-cache-dir -r requirements.txt # Copy the application code COPY app.py download_model.py start.sh ./ RUN chmod +x start.sh # Create cache directories with proper permissions RUN mkdir -p /tmp/transformers_cache /tmp/hf_home /tmp/hf_hub_cache /tmp/matplotlib_config RUN chown -R user:user /app /tmp/transformers_cache /tmp/hf_home /tmp/hf_hub_cache /tmp/matplotlib_config RUN chmod 777 /tmp/transformers_cache /tmp/hf_home /tmp/hf_hub_cache /tmp/matplotlib_config # Set environment variables ENV PYTHONUNBUFFERED=1 ENV GRADIO_SERVER_NAME=0.0.0.0 ENV GRADIO_SERVER_PORT=7860 ENV TRANSFORMERS_CACHE=/tmp/transformers_cache ENV HF_HOME=/tmp/hf_home ENV HUGGINGFACE_HUB_CACHE=/tmp/hf_hub_cache ENV MPLCONFIGDIR=/tmp/matplotlib_config # Switch to non-root user USER user # Expose the port EXPOSE 7860 # Command to run the application CMD ["./start.sh"]