# # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker # # you will also find guides on how best to write your Dockerfile # FROM python:3.9 # # Install system dependencies for OpenCV # RUN apt-get update && apt-get install -y \ # libgl1-mesa-glx \ # libglib2.0-0 \ # && rm -rf /var/lib/apt/lists/* # RUN useradd -m -u 1000 user # USER user # ENV PATH="/home/user/.local/bin:$PATH" # WORKDIR /app # COPY --chown=user ./requirements.txt requirements.txt # RUN pip install --no-cache-dir --upgrade -r requirements.txt # COPY --chown=user . /app # CMD ["gunicorn", "-b", "0.0.0.0:7860","app:app"] # Use the official Python image as the base image FROM python:3.9-slim # Install system dependencies for OpenCV and any other required libraries RUN apt-get update && apt-get install -y \ libgl1-mesa-glx \ libglib2.0-0 \ libx11-dev \ && rm -rf /var/lib/apt/lists/* # Create a non-root user and set permissions (safer and best practice) RUN useradd -m -u 1000 user # Switch to the non-root user USER user ENV PATH="/home/user/.local/bin:$PATH" # Set working directory WORKDIR /app # Copy requirements.txt and install Python dependencies COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of the application files to the container COPY --chown=user . /app # Expose the default port used by Hugging Face Spaces (usually 7860) EXPOSE 7860 # Define the command to run the app (assuming you're using Gunicorn to run a web app) CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]