From 7c160f272f26fcb1b0e281ff3d5ad9d2097cdf81 Mon Sep 17 00:00:00 2001 From: Sonic Shih Date: Fri, 24 Jul 2026 01:06:42 +0800 Subject: [PATCH 1/3] ci(polymarket): publish market recorder image --- .github/workflows/acr-publish.yml | 19 ++++++++- .../Dockerfile.polymarket-market-recorder | 42 +++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder diff --git a/.github/workflows/acr-publish.yml b/.github/workflows/acr-publish.yml index 0a0ecbbfa..eb04ddeba 100644 --- a/.github/workflows/acr-publish.yml +++ b/.github/workflows/acr-publish.yml @@ -14,6 +14,7 @@ on: - hft-trading - binance-lob-archiver - polymarket-evidence-compiler + - polymarket-market-recorder permissions: contents: read @@ -34,14 +35,15 @@ jobs: TARGET: ${{ inputs.target }} run: | case "$TARGET" in - all|research-runner|hft-trading|binance-lob-archiver|polymarket-evidence-compiler) ;; + all|research-runner|hft-trading|binance-lob-archiver|polymarket-evidence-compiler|polymarket-market-recorder) ;; *) echo "Unsupported publish target: $TARGET" >&2; exit 1 ;; esac matrix=$(jq -cn --arg target "$TARGET" ' [{repository:"research-runner",file:"rust_hft/deployment/docker/Dockerfile.research",target:"prebuilt"}, {repository:"hft-trading",file:"rust_hft/deployment/docker/Dockerfile.trading",target:"runtime"}, {repository:"binance-lob-archiver",file:"rust_hft/deployment/docker/Dockerfile.binance-lob-archiver",target:"runtime"}, - {repository:"polymarket-evidence-compiler",file:"rust_hft/deployment/docker/Dockerfile.polymarket-evidence-compiler",target:"runtime"}] + {repository:"polymarket-evidence-compiler",file:"rust_hft/deployment/docker/Dockerfile.polymarket-evidence-compiler",target:"runtime"}, + {repository:"polymarket-market-recorder",file:"rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder",target:"runtime"}] | {include: map(select($target == "all" or .repository == $target))}') echo "matrix=$matrix" >> "$GITHUB_OUTPUT" @@ -203,6 +205,19 @@ jobs: "$IMAGE") test "$actual_source_revision" = "$SOURCE_REVISION" + - name: Verify Polymarket market recorder image + if: matrix.repository == 'polymarket-market-recorder' + env: + IMAGE: ${{ vars.ACR_REGISTRY }}/wildcard0923/${{ matrix.repository }}@${{ steps.build.outputs.digest }} + SOURCE_REVISION: ${{ github.sha }} + run: | + docker pull "$IMAGE" + actual_source_revision=$(docker image inspect \ + --format '{{ index .Config.Labels "org.opencontainers.image.revision" }}' \ + "$IMAGE") + test "$actual_source_revision" = "$SOURCE_REVISION" + docker run --rm "$IMAGE" --help 2>&1 | grep -Fq -- '--dry-run' + - name: Verify research runner image if: matrix.repository == 'research-runner' env: diff --git a/rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder b/rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder new file mode 100644 index 000000000..3dceca943 --- /dev/null +++ b/rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder @@ -0,0 +1,42 @@ +# syntax=docker/dockerfile:1.7 + +FROM rust:1.91-bookworm AS builder + +WORKDIR /work +RUN apt-get update && apt-get install -y --no-install-recommends \ + clang \ + cmake \ + mold \ + pkg-config \ + && rm -rf /var/lib/apt/lists/* + +COPY prediction-markets/ prediction-markets/ +WORKDIR /work/prediction-markets +RUN if cargo tree --locked -p new-ploy-runner --features full -e features \ + | grep -q 'live-execution'; then \ + echo "new-ploy-runner full feature must not enable live-execution" >&2; \ + exit 1; \ + fi \ + && cargo --config 'build.rustc-wrapper=""' build \ + --release \ + --locked \ + -p new-ploy-runner \ + --features full \ + && install -D -m 0755 target/release/new-ploy-runner \ + /out/bin/new-ploy-runner + +FROM debian:bookworm-slim AS runtime + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + tini \ + && rm -rf /var/lib/apt/lists/* \ + && useradd --create-home --uid 1000 recorder + +WORKDIR /work +COPY --from=builder /out/bin/new-ploy-runner /usr/local/bin/new-ploy-runner + +USER recorder +ENV RUST_LOG=info +ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/new-ploy-runner"] +CMD ["--help"] From 1eb35827def1290b66b9af963407c66837d396aa Mon Sep 17 00:00:00 2001 From: Sonic Shih Date: Fri, 24 Jul 2026 01:12:01 +0800 Subject: [PATCH 2/3] fix(ci): include recorder workspace dependencies --- .../docker/Dockerfile.polymarket-market-recorder | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder b/rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder index 3dceca943..e76124c22 100644 --- a/rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder +++ b/rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder @@ -10,9 +10,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ pkg-config \ && rm -rf /var/lib/apt/lists/* -COPY prediction-markets/ prediction-markets/ +COPY . . WORKDIR /work/prediction-markets -RUN if cargo tree --locked -p new-ploy-runner --features full -e features \ +RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \ + --mount=type=cache,target=/usr/local/cargo/git,sharing=locked \ + --mount=type=cache,target=/work/prediction-markets/target,sharing=locked \ + if cargo tree --locked -p new-ploy-runner --features full -e features \ | grep -q 'live-execution'; then \ echo "new-ploy-runner full feature must not enable live-execution" >&2; \ exit 1; \ From 8b1eb489cfafe61221d44a2daf73510e0b30f3b2 Mon Sep 17 00:00:00 2001 From: Sonic Shih Date: Fri, 24 Jul 2026 01:16:25 +0800 Subject: [PATCH 3/3] fix(polymarket): require recorder dry run --- .github/workflows/acr-publish.yml | 8 +++++++- .../Dockerfile.polymarket-market-recorder | 4 +++- .../polymarket-market-recorder-entrypoint.sh | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 rust_hft/deployment/docker/polymarket-market-recorder-entrypoint.sh diff --git a/.github/workflows/acr-publish.yml b/.github/workflows/acr-publish.yml index eb04ddeba..fec826c8f 100644 --- a/.github/workflows/acr-publish.yml +++ b/.github/workflows/acr-publish.yml @@ -216,7 +216,13 @@ jobs: --format '{{ index .Config.Labels "org.opencontainers.image.revision" }}' \ "$IMAGE") test "$actual_source_revision" = "$SOURCE_REVISION" - docker run --rm "$IMAGE" --help 2>&1 | grep -Fq -- '--dry-run' + if output=$(docker run --rm "$IMAGE" --config /nonexistent 2>&1); then + echo "recorder accepted an invocation without --dry-run" >&2 + exit 1 + fi + grep -Fq 'requires --dry-run' <<<"$output" + docker run --rm "$IMAGE" --dry-run --help 2>&1 \ + | grep -Fq -- '--dry-run' - name: Verify research runner image if: matrix.repository == 'research-runner' diff --git a/rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder b/rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder index e76124c22..fcd819ca4 100644 --- a/rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder +++ b/rust_hft/deployment/docker/Dockerfile.polymarket-market-recorder @@ -38,8 +38,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /work COPY --from=builder /out/bin/new-ploy-runner /usr/local/bin/new-ploy-runner +COPY --chmod=0755 deployment/docker/polymarket-market-recorder-entrypoint.sh \ + /usr/local/bin/polymarket-market-recorder-entrypoint USER recorder ENV RUST_LOG=info -ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/new-ploy-runner"] +ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/polymarket-market-recorder-entrypoint"] CMD ["--help"] diff --git a/rust_hft/deployment/docker/polymarket-market-recorder-entrypoint.sh b/rust_hft/deployment/docker/polymarket-market-recorder-entrypoint.sh new file mode 100644 index 000000000..ca61d971b --- /dev/null +++ b/rust_hft/deployment/docker/polymarket-market-recorder-entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/sh +set -eu + +dry_run=false +help=false +for arg in "$@"; do + case "$arg" in + --dry-run) dry_run=true ;; + --help|-h) help=true ;; + esac +done + +if [ "$dry_run" = true ] || [ "$help" = true ]; then + exec /usr/local/bin/new-ploy-runner "$@" +fi + +echo "polymarket-market-recorder requires --dry-run" >&2 +exit 64