| # Use a Python base image | |
| FROM python:3.11-slim | |
| # Set the working directory | |
| WORKDIR /code | |
| # Install git to clone the repo | |
| RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* | |
| # Clone the repository into the current directory | |
| RUN git clone https://github.com/koo1140/OpenAgent . | |
| # Install dependencies | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Create a user to avoid running as root (HF requirement/best practice) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Override the port using an Environment Variable or Command Line Argument | |
| # Since the script has hardcoded port=8000, we run it via the uvicorn CLI | |
| # to bypass the main.py hardcoding. | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |