# Use an official lightweight Python image FROM python:3.11-slim # Create a non-root user that Hugging Face requires (User ID 1000) RUN useradd -m -u 1000 user USER user # Set up the environment paths for the new user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Set the working directory WORKDIR $HOME/app # Copy your requirements and install them COPY --chown=user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy all your application code and models into the container COPY --chown=user . . # Switch to root temporarily to create the /tmp/ folders and grant open permissions USER root RUN mkdir -p /tmp/tag_and_trail_downloads /tmp/tag_and_trail_uploads && \ chmod -R 777 /tmp/tag_and_trail_downloads /tmp/tag_and_trail_uploads # Switch back to the safe user USER user # Expose Hugging Face's mandatory port EXPOSE 7860 # Command to boot up your ML Brain CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]