# syntax=docker/dockerfile:1.6 ARG DEBIAN_IMAGE=debian:bookworm-slim ARG P2POOL_VERSION=v4.9 FROM ${DEBIAN_IMAGE} AS fetch ARG TARGETARCH ARG P2POOL_VERSION RUN set -eux; \ apt-get update; \ apt-get install -y --no-install-recommends ca-certificates curl jq xz-utils tar unzip; \ update-ca-certificates; \ rm -rf /var/lib/apt/lists/* # Pick the correct asset URL for our arch from the release metadata RUN set -eux; \ case "${TARGETARCH:-arm64}" in \ amd64) ARCH_RE='(x86_64|amd64)';; \ arm64) ARCH_RE='(arm64|aarch64|armv8)';; \ arm) ARCH_RE='(arm|armv7|armhf)';; \ *) echo "Unsupported TARGETARCH=${TARGETARCH}"; exit 1;; \ esac; \ API="https://api.github.com/repos/SChernykh/p2pool/releases/tags/${P2POOL_VERSION}"; \ URL="$(curl -fsSL "$API" | jq -r --arg re "$ARCH_RE" \ '.assets[] | select((.name|test("linux")) and (.name|test($re))) | .browser_download_url' | head -n1)"; \ test -n "$URL"; \ echo "Downloading $URL"; \ mkdir -p /tmp/p2pool; \ curl -fsSL "$URL" -o /tmp/p2pool/p2pool.tar; \ # try both common formats ( tar -xOf /tmp/p2pool/p2pool.tar >/dev/null 2>&1 && tar -xf /tmp/p2pool/p2pool.tar -C /tmp/p2pool ) \ || ( tar -xzf /tmp/p2pool/p2pool.tar -C /tmp/p2pool || tar -xJf /tmp/p2pool/p2pool.tar -C /tmp/p2pool ); \ # find the p2pool binary and install as a stable name P="$(find /tmp/p2pool -maxdepth 2 -type f -name 'p2pool' | head -n1)"; \ test -n "$P"; \ install -m 0755 "$P" /usr/local/bin/p2pool FROM ${DEBIAN_IMAGE} RUN set -eux; \ apt-get update; \ apt-get install -y --no-install-recommends ca-certificates; \ update-ca-certificates; \ rm -rf /var/lib/apt/lists/* COPY --from=fetch /usr/local/bin/p2pool /usr/local/bin/p2pool EXPOSE 3333 ENTRYPOINT ["p2pool"]