FROM python:3.9-slim # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ libgl1 \ libglib2.0-0 \ protobuf-compiler \ git \ && rm -rf /var/lib/apt/lists/* RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ PYTHONPATH=$HOME/app:$HOME/app/models/research:$HOME/app/models/research/slim WORKDIR $HOME/app RUN git clone --depth 1 https://github.com/tensorflow/models.git WORKDIR $HOME/app/models/research RUN protoc object_detection/protos/*.proto --python_out=. RUN cp object_detection/packages/tf2/setup.py . && \ python -m pip install --no-cache-dir . WORKDIR $HOME/app COPY --chown=user requirements.txt . RUN pip install --no-cache-dir -U -r requirements.txt COPY --chown=user . . CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]