# Use NVIDIA CUDA base image for GPU support FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04 # Set working directory WORKDIR /app # Install Python 3.11 and necessary tools RUN apt-get update --fix-missing && apt-get install -y --no-install-recommends \ python3.11 \ python3.11-dev \ python3-pip \ git \ gcc \ build-essential \ ffmpeg \ && rm -rf /var/lib/apt/lists/* \ && ln -sf /usr/bin/python3.11 /usr/bin/python3 \ && ln -sf /usr/bin/python3.11 /usr/bin/python # Set Hugging Face cache directory ENV TRANSFORMERS_CACHE=/app/.cache/huggingface ENV HF_HOME=/app/.cache/huggingface RUN mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache/huggingface # Copy requirements file COPY requirements.txt . # Update pip and install pip-tools RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir pip-tools # Sync dependencies with pip-sync RUN pip-sync requirements.txt # Install Gradio, diffusers, and LoRA packages RUN pip install --no-cache-dir gradio==4.44.0 RUN pip install --no-cache-dir diffusers==0.30.3 RUN pip install --no-cache-dir huggingface_hub==0.25.2 RUN pip install git+https://github.com/cloneofsimo/lora.git RUN pip install git+https://github.com/microsoft/LoRA # Copy the rest of the application code COPY . . # Expose Gradio default port EXPOSE 7860 # Set environment variable to prevent Python buffering ENV PYTHONUNBUFFERED=1 # Run the Gradio app CMD ["python", "app.py"]