# 1. Grab a lightweight Linux machine with Python installed FROM python:3.9-slim # 2. Set the working directory inside the server WORKDIR /code # 3. Copy your requirements file and install the AI libraries COPY ./requirements.txt /code/requirements.txt RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt # 4. Hugging Face Security Requirement: Create a non-root user RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # 5. Copy your Python script and AI weights into the server WORKDIR $HOME/app COPY --chown=user . $HOME/app # 6. Open port 7860 (This is the specific port Hugging Face listens to) EXPOSE 7860 # 7. Boot the FastAPI server! (UPDATED FOR app.py) CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]