consuming custom images

This commit is contained in:
Brad Stein 2025-08-14 00:47:10 -05:00
parent ca8b4fd6c3
commit b891ed7f72
4 changed files with 37 additions and 42 deletions

View File

@ -1,11 +1,7 @@
# syntax=docker/dockerfile:1.6
ARG DEBIAN_IMAGE=debian:bookworm-slim
ARG P2POOL_VERSION=4.9
ARG P2POOL_VERSION=v4.9
################################################################################
# Stage: fetch — download & extract the right release asset, normalize to /opt/bin/p2pool
################################################################################
FROM ${DEBIAN_IMAGE} AS fetch
ARG TARGETARCH
ARG P2POOL_VERSION
@ -16,6 +12,7 @@ RUN set -eux; \
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)';; \
@ -23,37 +20,28 @@ RUN set -eux; \
arm) ARCH_RE='(arm|armv7|armhf)';; \
*) echo "Unsupported TARGETARCH=${TARGETARCH}"; exit 1;; \
esac; \
API_URL="https://api.github.com/repos/SChernykh/p2pool/releases/tags/v${P2POOL_VERSION}"; \
ASSET_URL="$(curl -fsSL -H 'Accept: application/vnd.github+json' "$API_URL" \
| jq -r --arg re "$ARCH_RE" \
'.assets[] | select((.name|test("linux")) and (.name|test($re))) | .browser_download_url' \
| head -n1)"; \
test -n "$ASSET_URL"; \
echo "Fetching $ASSET_URL"; \
curl -fL "$ASSET_URL" -o /tmp/p2pool.pkg; \
mkdir -p /tmp/ex && cd /tmp/ex; \
case "$ASSET_URL" in \
*.tar.xz) tar -xJf /tmp/p2pool.pkg ;; \
*.tar.gz) tar -xzf /tmp/p2pool.pkg ;; \
*.zip) unzip -q /tmp/p2pool.pkg ;; \
*) echo "Unknown archive format: $ASSET_URL"; exit 1 ;; \
esac; \
BIN="$(find . -maxdepth 2 -type f -name 'p2pool*' -executable | sort | head -n1)"; \
test -n "$BIN"; \
install -Dm0755 "$BIN" /opt/bin/p2pool; \
/opt/bin/p2pool --help >/dev/null 2>&1 || true
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
################################################################################
# Stage: runtime
################################################################################
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 /opt/bin/p2pool /usr/local/bin/p2pool
COPY --from=fetch /usr/local/bin/p2pool /usr/local/bin/p2pool
EXPOSE 3333
ENTRYPOINT ["p2pool"]

View File

@ -1,30 +1,36 @@
# syntax=docker/dockerfile:1.6
FROM debian:bookworm-slim
ARG DEBIAN_IMAGE=debian:bookworm-slim
ARG MONERO_VERSION=v0.18.4.1
FROM ${DEBIAN_IMAGE}
ARG TARGETARCH
ARG MONERO_SHA256=""
ARG MONERO_VERSION
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates curl bzip2; \
update-ca-certificates; \
rm -rf /var/lib/apt/lists/*
RUN set -eux; \
case "${TARGETARCH:-arm64}" in \
amd64) F="monero-linux-x64" ;; \
amd64) F="monero-linux-x64" ;; \
arm64) F="monero-linux-armv8" ;; \
arm) F="monero-linux-armv7" ;; \
*) echo "Unsupported TARGETARCH=${TARGETARCH}"; exit 1 ;; \
esac; \
URL="https://downloads.getmonero.org/cli/${F}-${MONERO_VERSION}.tar.bz2"; \
echo "Downloading $URL"; \
curl -fL "$URL" -o /tmp/monero.tar.bz2; \
if [ -n "$MONERO_SHA256" ]; then echo "${MONERO_SHA256} /tmp/monero.tar.bz2" | sha256sum -c -; fi; \
mkdir -p /opt/monero; \
tar -xjf /tmp/monero.tar.bz2 -C /opt/monero --strip-components=1; \
rm -f /tmp/monero.tar.bz2; \
mkdir -p /data
curl -fsSL "$URL" -o /opt/monero/monero.tar.bz2; \
tar -xjf /opt/monero/monero.tar.bz2 -C /opt/monero --strip-components=1; \
rm -f /opt/monero/monero.tar.bz2; \
install -m 0755 /opt/monero/monero-* /usr/local/bin/ || true; \
install -m 0755 /opt/monero/monerod /usr/local/bin/ || true; \
install -m 0755 /opt/monero/monero-wallet-rpc /usr/local/bin/
ENV LD_LIBRARY_PATH=/opt/monero:/opt/monero/lib \
PATH="/opt/monero:${PATH}"
RUN /usr/local/bin/monero-wallet-rpc --version || true
EXPOSE 18083
ENTRYPOINT ["monero-wallet-rpc"]
CMD ["monero-wallet-rpc","--version"]

View File

@ -512,7 +512,7 @@ function walletsvc_bootstrap --description "Interactive setup of monero-wallet-r
echo " containers:"
echo " - name: wallet-rpc"
echo " image: $image"
echo " imagePullPolicy: IfNotPresent"
echo " imagePullPolicy: Always"
echo " command: [\"/bin/sh\",\"-lc\"]"
echo " args:"
echo " - |"

View File

@ -18,6 +18,7 @@ spec:
containers:
- name: monero-p2pool
image: registry.bstein.dev/infra/monero-p2pool:4.9
imagePullPolicy: Always
command: ["p2pool"]
args:
- "--host"