fix: pin reverse-SynthID build and fix Dockerfile ARG scope (#5)

This commit is contained in:
Carlos Maeda
2026-08-12 20:45:07 -07:00
committed by GitHub
parent 25da732ec8
commit 4b4c942635
3 changed files with 36 additions and 14 deletions
+14 -4
View File
@@ -6,10 +6,19 @@
# The upstream code is fetched from source at build time and is NOT
# redistributed by this repository. Users must comply with the upstream
# project's non-commercial Research License.
#
# Vendored fork hardening:
# - base image pinned by digest (no moving tag drift)
# - upstream checkout pinned to a commit SHA (no moving branch)
# - deps pinned exactly in requirements-synthid-scorer.txt
FROM python:3.11-slim
# Pinned upstream commit (2026-07-17). Keep in sync with setup_synthid.sh.
ARG REVERSE_SYNTHID_REF=b11083676fd3ee3ff97ce9d03c0e409e46905902
ARG REVERSE_SYNTHID_REF=main
# python:3.11-slim linux/amd64 digest.
FROM python:3.11-slim@sha256:78b39ef14d8e2b4d71f8dc304f1328c37df95fe0ef99477c2ae6bd3d03784553
ARG REVERSE_SYNTHID_REF
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@@ -19,9 +28,10 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*
RUN git clone --depth 1 --filter=blob:none --sparse \
--branch "${REVERSE_SYNTHID_REF}" \
https://github.com/aloshdenny/reverse-SynthID.git /opt/reverse-synthid \
&& cd /opt/reverse-synthid \
&& git fetch --depth 1 origin "${REVERSE_SYNTHID_REF}" \
&& git checkout --detach "${REVERSE_SYNTHID_REF}" \
&& git sparse-checkout set --no-cone \
'/src/' \
'/artifacts/spectral_codebook_v4.npz' \
@@ -37,4 +47,4 @@ RUN pip install --no-cache-dir -r /app/requirements-synthid-scorer.txt
ENV REVERSE_SYNTHID_DIR=/opt/reverse-synthid
WORKDIR /app
ENTRYPOINT ["python3", "/app/score_synthid.py"]
ENTRYPOINT ["python3", "/app/score_synthid.py"]
@@ -1,9 +1,13 @@
# Minimal dependencies for the optional reverse-SynthID pixel scorer.
# The upstream repo's full requirements.txt adds torch/diffusers and other
# packages only needed for its VAE/bypass pipeline, which this project does not use.
numpy>=1.21.0
scipy>=1.7.0
opencv-python>=4.5.0
PyWavelets>=1.1.1
scikit-learn>=0.24.0
Pillow>=8.0.0
#
# Vendored fork hardening: exact pins (no drift). Re-evaluate versions before
# bumping and pin the upstream checkout in setup_synthid.sh / Dockerfile.synthid
# to a matching commit.
numpy==2.0.2
scipy==1.14.1
opencv-python==4.10.0.84
PyWavelets==1.7.0
scikit-learn==1.5.2
Pillow==10.4.0
@@ -11,7 +11,8 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DEFAULT_DIR="${REVERSE_SYNTHID_DIR:-$HOME/reverse-SynthID}"
DIR=""
REF="main"
# Pinned upstream commit (2026-07-17). Do not point at a moving branch.
REF="b11083676fd3ee3ff97ce9d03c0e409e46905902"
PYTHON="${PYTHON:-python3}"
FULL=0
@@ -24,7 +25,7 @@ the Python dependencies required by score_synthid.py.
Options:
--dir PATH checkout directory (default: $REVERSE_SYNTHID_DIR or ~/reverse-SynthID)
--ref REF git ref to clone (default: main)
--ref REF git ref to checkout (default: pinned commit SHA)
--full install upstream requirements.txt (adds torch/diffusers for VAE bypass)
--python PY Python interpreter used to create the venv (default: python3)
EOF
@@ -69,15 +70,22 @@ else
fi
if [[ ! -d "$DIR/.git" ]]; then
echo "Cloning reverse-SynthID into $DIR"
git clone --depth 1 --filter=blob:none --sparse --branch "$REF" \
echo "Cloning reverse-SynthID into $DIR (pinned ref: $REF)"
git clone --depth 1 --filter=blob:none --sparse \
https://github.com/aloshdenny/reverse-SynthID.git "$DIR"
git -C "$DIR" fetch --depth 1 origin "$REF"
git -C "$DIR" checkout --detach "$REF"
git -C "$DIR" sparse-checkout set --no-cone \
'/src/' \
'/artifacts/spectral_codebook_v4.npz' \
'/requirements.txt' \
'/LICENSE' \
'/README.md'
HEAD_SHA="$(git -C "$DIR" rev-parse HEAD)"
if [[ "$HEAD_SHA" != "$REF" ]]; then
echo "error: expected pinned ref $REF, got $HEAD_SHA" >&2
exit 1
fi
else
echo "Using existing checkout: $DIR"
fi