titan-iac/dockerfiles/Dockerfile.monero-p2pool

48 lines
1.8 KiB
Docker
Raw Normal View History

# syntax=docker/dockerfile:1.6
2025-08-14 00:34:13 -05:00
ARG DEBIAN_IMAGE=debian:bookworm-slim
2025-08-14 00:47:10 -05:00
ARG P2POOL_VERSION=v4.9
2025-08-14 00:34:13 -05:00
FROM ${DEBIAN_IMAGE} AS fetch
ARG TARGETARCH
2025-08-14 00:34:13 -05:00
ARG P2POOL_VERSION
RUN set -eux; \
apt-get update; \
2025-08-14 00:34:13 -05:00
apt-get install -y --no-install-recommends ca-certificates curl jq xz-utils tar unzip; \
update-ca-certificates; \
2025-08-14 00:34:13 -05:00
rm -rf /var/lib/apt/lists/*
2025-08-14 00:47:10 -05:00
# Pick the correct asset URL for our arch from the release metadata
2025-08-14 00:34:13 -05:00
RUN set -eux; \
case "${TARGETARCH:-arm64}" in \
2025-08-14 00:34:13 -05:00
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; \
2025-08-14 00:47:10 -05:00
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
2025-08-14 00:34:13 -05:00
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/*
2025-08-14 00:47:10 -05:00
COPY --from=fetch /usr/local/bin/p2pool /usr/local/bin/p2pool
EXPOSE 3333
2025-08-14 00:34:13 -05:00
ENTRYPOINT ["p2pool"]