| FROM python:3.11-slim | |
| # Set up a new user named "user" with UID 1000 | |
| RUN useradd -m -u 1000 user | |
| # Setup writeable cache and data directories under /tmp | |
| ENV HOME=/tmp \ | |
| PORT=7860 | |
| WORKDIR /code | |
| # Copy and install python dependencies | |
| COPY requirements.txt /code/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| # Copy application code | |
| COPY --chown=user:user . /code | |
| # Set user to 1000 | |
| USER user | |
| EXPOSE 7860 | |
| # Run FastAPI/Gradio server | |
| CMD ["python", "app.py"] | |