FROM python:3.9 # Create a non-root user RUN useradd -m -u 1000 user # Set up the app directory and copy files WORKDIR /app COPY --chown=user:user . . # Explicitly create and set ownership for the cache directory RUN mkdir -p /home/user/.cache/huggingface && \ chown -R user:user /home/user/.cache # Switch to the user USER user # Force install a compatible Gradio version, then install other requirements RUN pip install gradio==4.20.1 && \ pip install -r requirements.txt --no-cache-dir # Expose the port and run the application EXPOSE 7860 CMD ["python", "app.py"]