FROM python:3.12-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ git \ && rm -rf /var/lib/apt/lists/* # Copy requirements and install COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy app COPY app.py . # Create a non-root user with proper home directory RUN useradd -m -u 1000 user ENV HOME=/home/user ENV HF_HOME=/home/user/.cache/huggingface ENV GRADIO_SERVER_NAME=0.0.0.0 ENV GRADIO_SERVER_PORT=7860 # Create cache directories and set permissions RUN mkdir -p /home/user/.cache/huggingface && \ chown -R user:user /home/user && \ chown -R user:user /app USER user WORKDIR /app # Expose port EXPOSE 7860 # Run the app CMD ["python", "app.py"]