# plato M0 S4.1: TF1.15 golden-extraction image (linux/amd64).
# Host is linux/amd64: `docker build -t plato-golden golden/extract` is sufficient
# (no buildx). The extractor writes .npz fixtures to /out.

FROM tensorflow/tensorflow:1.15.5-py3@sha256:181ff142e73ed8efe350f49288c7b0f5681fde66534a76d8de4fc75d4e30d571

# ---------------------------------------------------------------------------
# Fallback base (M0 §3) - not used. To switch: comment the FROM above and
# uncomment this block (including the tensorflow wheel install).
# FROM python:3.7@sha256:eedf63967cdb57d8214db38ce21f105003ed4e4d0358f02bedc057341bcf92a0
# RUN pip install --no-cache-dir tensorflow==1.15.5
# ---------------------------------------------------------------------------

ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONPATH=/opt/dnc \
    PYTHONDONTWRITEBYTECODE=1 \
    TF_CPP_MIN_LOG_LEVEL=2

RUN apt-get update \
    && apt-get install -y --no-install-recommends git ca-certificates \
    && rm -rf /var/lib/apt/lists/*

COPY requirements.txt /opt/requirements.txt
RUN pip install --no-cache-dir -r /opt/requirements.txt

# DNC reference cloned at build time (not a run-time mount). Commit is the
# full SHA of f5981c6 (M0 §0.3 / execution-plan P1).
RUN git clone https://github.com/google-deepmind/dnc /opt/dnc \
    && cd /opt/dnc \
    && git checkout f5981c66ac6fe27978014c314c4aba39f1962ee3

RUN python -c "import tensorflow, sonnet, dnc"

RUN pip freeze > /opt/requirements.lock.txt

COPY extract.py /opt/extract.py
ENTRYPOINT ["python", "/opt/extract.py"]
