# Build the ordinary image first; this adds an isolated SAM runtime. # SAM weights are mounted at runtime, never embedded using a build-time token. ARG BASE_IMAGE=baseball-engine-api:local FROM ${BASE_IMAGE} USER root RUN apt-get update && apt-get install -y --no-install-recommends git build-essential libgl1 libegl1 libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* COPY requirements-sam.txt ./ RUN python -m venv /opt/sam-runtime \ && /opt/sam-runtime/bin/python -m pip install torch==2.9.1 torchvision==0.24.1 --index-url https://download.pytorch.org/whl/cu128 \ && /opt/sam-runtime/bin/python -m pip install -r requirements-core.txt -r requirements-sam.txt \ && /opt/sam-runtime/bin/python -m pip install git+https://github.com/facebookresearch/detectron2.git@a1ce2f9 --no-build-isolation --no-deps \ && git clone https://github.com/facebookresearch/sam-3d-body.git /opt/sam-source \ && git -C /opt/sam-source checkout b5c765a0d89d789985e186d396315e7590887b94 \ && chown -R baseball:baseball /opt/sam-source ENV BASEBALL_SAM_WORKER_RECORD=/opt/sam-assets/sam-api-worker.json USER baseball