| FROM ultralytics/ultralytics | |
| # Create a non-root user and group with specific IDs | |
| RUN useradd -m -u 1000 user | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends \ | |
| libgtk2.0-dev \ | |
| libgl1-mesa-glx \ | |
| && rm -rf /var/lib/apt/lists/* | |
| ENV DEBIAN_FRONTEND= | |
| # Set the working directory | |
| WORKDIR /app | |
| # Copy the application code and change ownership to the 'user' | |
| COPY --chown=user:user . /app | |
| # Install required Python packages | |
| RUN pip install gradio | |
| # Create necessary directories and set ownership to 'user' | |
| RUN mkdir -p /app/videos /app/results && chown -R user:user /app | |
| # Switch to the 'user' account | |
| USER user | |
| EXPOSE 7860 | |
| # Environment variables | |
| ENV PYTHONUNBUFFERED=1 \ | |
| GRADIO_ALLOW_FLAGGING=never \ | |
| GRADIO_NUM_PORTS=1 \ | |
| GRADIO_SERVER_NAME=0.0.0.0 \ | |
| SYSTEM=spaces | |
| # Command to run the application | |
| CMD ["python", "app.py"] | |