Align Dockerfile and entrypoint with upstream KamadoPool build

Previous scaffold referenced a non-existent 'make ckpool-src'
target. Rewritten to inline the real build steps from the
upstream KamadoPool repo: clone ckpool at CKPOOL_COMMIT, apply
patches/*.patch, build with the same portable CFLAGS the
ckpool Dockerfile uses. The ui and api stages now match
api/Dockerfile exactly.

Entrypoint now uses the same env-var interface as the upstream
ckpool entrypoint (POOL_BTCADDRESS, BITCOIN_RPC_*, STRATUM_PORT,
etc.) and renders ckpool.conf from the bundled template via
sed. kamado-api env vars corrected to match config.FromEnv
(BITCOIN_RPC_URL, CKPOOL_SOCKDIR, CKPOOL_LOGFILE, LISTEN_ADDR).
This commit is contained in:
satoshi
2026-04-13 18:10:17 +03:00
parent 54935bf638
commit 90e745f160
2 changed files with 98 additions and 72 deletions
+40 -20
View File
@@ -2,19 +2,22 @@
# #
# Kamado Pool StartOS package image. # Kamado Pool StartOS package image.
# #
# Clones KamadoPool at a pinned SHA, builds the patched ckpool-solo # Clones the KamadoPool repo at a pinned SHA, then inlines the ckpool,
# binary, builds the Go api binary with embedded Svelte UI, then # ui, and api build stages (mirroring ckpool/Dockerfile and api/Dockerfile
# assembles a small runtime image that supervises both processes. # in the upstream repo). Final runtime image has both binaries plus the
# StartOS entrypoint that supervises them.
# #
# TODO: set KAMADO_REPO + KAMADO_SHA to a pushed commit before # TODO: set KAMADO_SHA to a real pushed commit before running `make`.
# running `make` — the defaults below are placeholders and the build # The placeholder below is a valid 40-char hex string to keep tooling
# WILL fail until the KamadoPool source repo is pushed to GitHub. # happy but the clone checkout will fail until this is updated.
ARG KAMADO_REPO=https://github.com/Relaxo143/KamadoPool.git ARG KAMADO_REPO=https://github.com/Relaxo143/KamadoPool.git
ARG KAMADO_SHA=0000000000000000000000000000000000000000 ARG KAMADO_SHA=0000000000000000000000000000000000000000
ARG CKPOOL_REPO=https://bitbucket.org/ckolivas/ckpool.git
ARG CKPOOL_COMMIT=cfb0f83b70d7b382b85d2bd0710cf4cb2dda4007
ARG ARCH ARG ARCH
# ---------- stage 1: fetch source ---------- # ---------- stage 1: fetch Kamado source ----------
FROM debian:bookworm-slim AS source FROM debian:bookworm-slim AS source
ARG KAMADO_REPO ARG KAMADO_REPO
ARG KAMADO_SHA ARG KAMADO_SHA
@@ -25,22 +28,34 @@ WORKDIR /src
RUN git clone "${KAMADO_REPO}" kamado \ RUN git clone "${KAMADO_REPO}" kamado \
&& cd kamado && git checkout "${KAMADO_SHA}" && cd kamado && git checkout "${KAMADO_SHA}"
# ---------- stage 2: build ckpool ---------- # ---------- stage 2: build patched ckpool ----------
# Mirrors KamadoPool/ckpool/Dockerfile: clones upstream ckpool at the
# pinned commit, applies Kamado patches, builds with portable CFLAGS.
FROM debian:bookworm-slim AS ckpool-build FROM debian:bookworm-slim AS ckpool-build
ARG CKPOOL_REPO
ARG CKPOOL_COMMIT
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential autoconf automake libtool pkg-config \ build-essential autoconf automake libtool pkg-config \
yasm libzmq3-dev git ca-certificates \ libzmq3-dev ca-certificates git \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY --from=source /src/kamado /src/kamado WORKDIR /build
WORKDIR /src/kamado RUN git clone "${CKPOOL_REPO}" ckpool \
RUN make ckpool-src \ && cd ckpool && git checkout "${CKPOOL_COMMIT}"
&& cd ckpool/src \ COPY --from=source /src/kamado/ckpool/patches/ /tmp/kamado-patches/
RUN set -eux; cd /build/ckpool; \
for p in /tmp/kamado-patches/*.patch; do \
[ -f "$p" ] || continue; \
echo "Applying $(basename "$p")"; \
git apply --verbose "$p"; \
done
RUN cd /build/ckpool \
&& ./autogen.sh \ && ./autogen.sh \
&& ./configure --without-ckdb --prefix=/usr/local \ && CFLAGS="-O2 -Wall -pipe" ./configure --prefix=/usr/local \
&& make -j"$(nproc)" \ && make -j"$(nproc)"
&& install -Dm755 src/ckpool /out/usr/local/bin/ckpool RUN install -Dm755 /build/ckpool/src/ckpool /out/usr/local/bin/ckpool \
&& install -Dm755 /build/ckpool/src/ckpmsg /out/usr/local/bin/ckpmsg
# ---------- stage 3: build UI ---------- # ---------- stage 3: build the Svelte UI ----------
FROM node:22-bookworm-slim AS ui-build FROM node:22-bookworm-slim AS ui-build
WORKDIR /ui WORKDIR /ui
COPY --from=source /src/kamado/ui/package.json ./ COPY --from=source /src/kamado/ui/package.json ./
@@ -48,9 +63,11 @@ RUN npm install --no-audit --no-fund
COPY --from=source /src/kamado/ui/ ./ COPY --from=source /src/kamado/ui/ ./
RUN npm run build RUN npm run build
# ---------- stage 4: build Go api with embedded UI ---------- # ---------- stage 4: build the Go api with embedded UI ----------
FROM golang:1.22-bookworm AS api-build FROM golang:1.22-bookworm AS api-build
WORKDIR /src WORKDIR /src
COPY --from=source /src/kamado/api/go.mod ./
RUN go mod download 2>/dev/null || true
COPY --from=source /src/kamado/api/ ./ COPY --from=source /src/kamado/api/ ./
RUN rm -rf internal/webui/dist && mkdir -p internal/webui/dist RUN rm -rf internal/webui/dist && mkdir -p internal/webui/dist
COPY --from=ui-build /ui/dist/ internal/webui/dist/ COPY --from=ui-build /ui/dist/ internal/webui/dist/
@@ -66,7 +83,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
tini ca-certificates curl libzmq5 \ tini ca-certificates curl libzmq5 \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# yq for parsing StartOS config.yaml inside the entrypoint # yq for reading StartOS config.yaml in the entrypoint
RUN set -eu; \ RUN set -eu; \
case "${ARCH}" in \ case "${ARCH}" in \
x86_64|amd64) YQ_ARCH=amd64 ;; \ x86_64|amd64) YQ_ARCH=amd64 ;; \
@@ -78,9 +95,12 @@ RUN set -eu; \
chmod +x /usr/local/bin/yq chmod +x /usr/local/bin/yq
COPY --from=ckpool-build /out/usr/local/bin/ckpool /usr/local/bin/ckpool COPY --from=ckpool-build /out/usr/local/bin/ckpool /usr/local/bin/ckpool
COPY --from=ckpool-build /out/usr/local/bin/ckpmsg /usr/local/bin/ckpmsg
COPY --from=api-build /out/kamado-api /usr/local/bin/kamado-api COPY --from=api-build /out/kamado-api /usr/local/bin/kamado-api
COPY --from=source /src/kamado/ckpool/config/ckpool.conf.template /etc/ckpool/ckpool.conf.template
COPY docker_entrypoint.sh /usr/local/bin/docker_entrypoint.sh COPY docker_entrypoint.sh /usr/local/bin/docker_entrypoint.sh
RUN chmod +x /usr/local/bin/docker_entrypoint.sh RUN chmod +x /usr/local/bin/docker_entrypoint.sh \
&& mkdir -p /run/ckpool /var/log/ckpool /var/lib/kamado
EXPOSE 3333 8080 EXPOSE 3333 8080
WORKDIR /root WORKDIR /root
+58 -52
View File
@@ -1,18 +1,14 @@
#!/bin/bash #!/bin/bash
# Kamado Pool StartOS entrypoint. # Kamado Pool StartOS entrypoint.
# #
# Renders ckpool.conf from /root/.kamado/start9/config.yaml, resolves # Reads /root/.kamado/start9/config.yaml via yq, resolves the chosen
# which bitcoind variant the user picked (mainnet vs testnet4), then # bitcoind variant (mainnet vs testnet4), exports the env vars the
# supervises ckpool and kamado-api as a pair — if either exits, tear # upstream ckpool entrypoint expects, renders ckpool.conf from the
# the container down so StartOS restarts the service cleanly. # template shipped alongside this script, and then supervises
# ckpool-solo + kamado-api as a pair.
set -euo pipefail set -euo pipefail
CONFIG_FILE="/root/.kamado/start9/config.yaml" CONFIG_FILE="/root/.kamado/start9/config.yaml"
CKPOOL_DIR="/root/.ckpool"
CKPOOL_CONF="${CKPOOL_DIR}/ckpool.conf"
CKPOOL_LOG_DIR="${CKPOOL_DIR}/logs"
mkdir -p "${CKPOOL_DIR}" "${CKPOOL_LOG_DIR}"
if [[ ! -f "${CONFIG_FILE}" ]]; then if [[ ! -f "${CONFIG_FILE}" ]]; then
echo "kamado-entrypoint: config file missing: ${CONFIG_FILE}" >&2 echo "kamado-entrypoint: config file missing: ${CONFIG_FILE}" >&2
exit 1 exit 1
@@ -23,12 +19,12 @@ q() { yq -r "$1" "${CONFIG_FILE}"; }
BITCOIND_VARIANT=$(q '.bitcoind.type') BITCOIND_VARIANT=$(q '.bitcoind.type')
case "${BITCOIND_VARIANT}" in case "${BITCOIND_VARIANT}" in
bitcoind) bitcoind)
BITCOIN_HOST="bitcoind.embassy" export BITCOIN_RPC_HOST="bitcoind.embassy"
BITCOIN_PORT=8332 export BITCOIN_RPC_PORT=8332
;; ;;
bitcoind-testnet) bitcoind-testnet)
BITCOIN_HOST="bitcoind-testnet.embassy" export BITCOIN_RPC_HOST="bitcoind-testnet.embassy"
BITCOIN_PORT=48332 export BITCOIN_RPC_PORT=48332
;; ;;
*) *)
echo "kamado-entrypoint: unknown bitcoind variant: ${BITCOIND_VARIANT}" >&2 echo "kamado-entrypoint: unknown bitcoind variant: ${BITCOIND_VARIANT}" >&2
@@ -36,53 +32,63 @@ case "${BITCOIND_VARIANT}" in
;; ;;
esac esac
BITCOIN_USER=$(q '.bitcoind.user') export BITCOIN_RPC_USER=$(q '.bitcoind.user')
BITCOIN_PASS=$(q '.bitcoind.password') export BITCOIN_RPC_PASSWORD=$(q '.bitcoind.password')
POOL_BTCADDRESS=$(q '.pool-address') export POOL_BTCADDRESS=$(q '.pool-address')
POOL_IDENTIFIER=$(q '.pool-identifier') export POOL_BTCSIG=$(q '.pool-identifier')
STRATUM_PORT=$(q '.stratum-port // 3333') export STRATUM_PORT=$(q '.stratum-port // 3333')
DROPIDLE=$(q '.dropidle // 0') export STARTDIFF=$(q '.startdiff // 16384')
STARTDIFF=$(q '.startdiff // 16384') export MINDIFF=$(q '.mindiff // 1000')
MINDIFF=$(q '.mindiff // 1000') export MAXDIFF=$(q '.maxdiff // 0')
MAXDIFF=$(q '.maxdiff // 0') export DROPIDLE=$(q '.dropidle // 0')
LOG_LEVEL=$(q '.log-level // "info"') LOG_LEVEL=$(q '.log-level // "info"')
cat > "${CKPOOL_CONF}" <<EOF export LOGDIR=/var/log/ckpool
{ export SOCKET_DIR=/run/ckpool
"btcd": [ export BITCOIN_NOTIFY=true
{ export ZMQ_BLOCK=""
"url": "${BITCOIN_HOST}:${BITCOIN_PORT}", export BLOCKPOLL_MS=100
"auth": "${BITCOIN_USER}", export UPDATE_INTERVAL_S=30
"pass": "${BITCOIN_PASS}", mkdir -p "${LOGDIR}" "${SOCKET_DIR}" /etc/ckpool
"notify": true
}
],
"btcaddress": "${POOL_BTCADDRESS}",
"btcsig": "${POOL_IDENTIFIER}",
"serverurl": [
"0.0.0.0:${STRATUM_PORT}"
],
"mindiff": ${MINDIFF},
"startdiff": ${STARTDIFF},
"maxdiff": ${MAXDIFF},
"logdir": "${CKPOOL_LOG_DIR}"
}
EOF
echo "kamado-entrypoint: starting ckpool (solo, ${BITCOIND_VARIANT})" # Render ckpool.conf using the same sed approach as the upstream
ckpool -B -c "${CKPOOL_CONF}" & # KamadoPool ckpool entrypoint — the template is bundled into the
# image at build time.
TEMPLATE=/etc/ckpool/ckpool.conf.template
CONF=/etc/ckpool/ckpool.conf
sed \
-e "s|\${BITCOIN_RPC_HOST}|${BITCOIN_RPC_HOST}|g" \
-e "s|\${BITCOIN_RPC_PORT}|${BITCOIN_RPC_PORT}|g" \
-e "s|\${BITCOIN_RPC_USER}|${BITCOIN_RPC_USER}|g" \
-e "s|\${BITCOIN_RPC_PASSWORD}|${BITCOIN_RPC_PASSWORD}|g" \
-e "s|\${BITCOIN_NOTIFY}|${BITCOIN_NOTIFY}|g" \
-e "s|\${POOL_BTCADDRESS}|${POOL_BTCADDRESS}|g" \
-e "s|\${POOL_BTCSIG}|${POOL_BTCSIG}|g" \
-e "s|\${BLOCKPOLL_MS}|${BLOCKPOLL_MS}|g" \
-e "s|\${UPDATE_INTERVAL_S}|${UPDATE_INTERVAL_S}|g" \
-e "s|\${STRATUM_PORT}|${STRATUM_PORT}|g" \
-e "s|\${MINDIFF}|${MINDIFF}|g" \
-e "s|\${STARTDIFF}|${STARTDIFF}|g" \
-e "s|\${MAXDIFF}|${MAXDIFF}|g" \
-e "s|\${DROPIDLE}|${DROPIDLE}|g" \
-e "s|\${LOGDIR}|${LOGDIR}|g" \
-e "s|\${ZMQ_BLOCK}|${ZMQ_BLOCK}|g" \
"${TEMPLATE}" > "${CONF}"
sed -i '/"zmqblock":/d' "${CONF}"
echo "kamado-entrypoint: starting ckpool (solo, ${BITCOIND_VARIANT}) on port ${STRATUM_PORT}"
/usr/local/bin/ckpool --btcsolo --config "${CONF}" --sockdir "${SOCKET_DIR}" --log-shares &
CKPOOL_PID=$! CKPOOL_PID=$!
export KAMADO_CKPOOL_SOCKET="${CKPOOL_DIR}/solo/listener" export LISTEN_ADDR=":8080"
export KAMADO_CKPOOL_LOGFILE="${CKPOOL_LOG_DIR}/ckpool.log" export CKPOOL_SOCKDIR="${SOCKET_DIR}"
export KAMADO_BITCOIND_URL="http://${BITCOIN_HOST}:${BITCOIN_PORT}" export CKPOOL_LOGFILE="${LOGDIR}/ckpool.log"
export KAMADO_BITCOIND_USER="${BITCOIN_USER}" export BITCOIN_RPC_URL="http://${BITCOIN_RPC_HOST}:${BITCOIN_RPC_PORT}"
export KAMADO_BITCOIND_PASS="${BITCOIN_PASS}" export POLL_INTERVAL=5s
export KAMADO_HTTP_ADDR=":8080"
export KAMADO_LOG_LEVEL="${LOG_LEVEL}" export KAMADO_LOG_LEVEL="${LOG_LEVEL}"
echo "kamado-entrypoint: starting kamado-api" echo "kamado-entrypoint: starting kamado-api"
kamado-api & /usr/local/bin/kamado-api &
API_PID=$! API_PID=$!
term() { term() {