Files
KamadoPool-StartOS-0351/Dockerfile
T
satoshi 90e745f160 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).
2026-04-13 18:10:17 +03:00

108 lines
4.2 KiB
Docker

# syntax=docker/dockerfile:1.6
#
# Kamado Pool StartOS package image.
#
# Clones the KamadoPool repo at a pinned SHA, then inlines the ckpool,
# ui, and api build stages (mirroring ckpool/Dockerfile and api/Dockerfile
# in the upstream repo). Final runtime image has both binaries plus the
# StartOS entrypoint that supervises them.
#
# TODO: set KAMADO_SHA to a real pushed commit before running `make`.
# The placeholder below is a valid 40-char hex string to keep tooling
# happy but the clone checkout will fail until this is updated.
ARG KAMADO_REPO=https://github.com/Relaxo143/KamadoPool.git
ARG KAMADO_SHA=0000000000000000000000000000000000000000
ARG CKPOOL_REPO=https://bitbucket.org/ckolivas/ckpool.git
ARG CKPOOL_COMMIT=cfb0f83b70d7b382b85d2bd0710cf4cb2dda4007
ARG ARCH
# ---------- stage 1: fetch Kamado source ----------
FROM debian:bookworm-slim AS source
ARG KAMADO_REPO
ARG KAMADO_SHA
RUN apt-get update && apt-get install -y --no-install-recommends \
git ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
RUN git clone "${KAMADO_REPO}" kamado \
&& cd kamado && git checkout "${KAMADO_SHA}"
# ---------- 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
ARG CKPOOL_REPO
ARG CKPOOL_COMMIT
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential autoconf automake libtool pkg-config \
libzmq3-dev ca-certificates git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
RUN git clone "${CKPOOL_REPO}" ckpool \
&& cd ckpool && git checkout "${CKPOOL_COMMIT}"
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 \
&& CFLAGS="-O2 -Wall -pipe" ./configure --prefix=/usr/local \
&& make -j"$(nproc)"
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 the Svelte UI ----------
FROM node:22-bookworm-slim AS ui-build
WORKDIR /ui
COPY --from=source /src/kamado/ui/package.json ./
RUN npm install --no-audit --no-fund
COPY --from=source /src/kamado/ui/ ./
RUN npm run build
# ---------- stage 4: build the Go api with embedded UI ----------
FROM golang:1.22-bookworm AS api-build
WORKDIR /src
COPY --from=source /src/kamado/api/go.mod ./
RUN go mod download 2>/dev/null || true
COPY --from=source /src/kamado/api/ ./
RUN rm -rf internal/webui/dist && mkdir -p internal/webui/dist
COPY --from=ui-build /ui/dist/ internal/webui/dist/
RUN CGO_ENABLED=0 GOOS=linux go build \
-trimpath -ldflags="-s -w" \
-o /out/kamado-api ./cmd/kamado-api
# ---------- stage 5: runtime ----------
FROM debian:bookworm-slim AS runtime
ARG ARCH
ARG YQ_VERSION=v4.44.3
RUN apt-get update && apt-get install -y --no-install-recommends \
tini ca-certificates curl libzmq5 \
&& rm -rf /var/lib/apt/lists/*
# yq for reading StartOS config.yaml in the entrypoint
RUN set -eu; \
case "${ARCH}" in \
x86_64|amd64) YQ_ARCH=amd64 ;; \
aarch64|arm64) YQ_ARCH=arm64 ;; \
*) echo "unsupported arch: ${ARCH}" >&2; exit 1 ;; \
esac; \
curl -fsSL -o /usr/local/bin/yq \
"https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${YQ_ARCH}"; \
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/ckpmsg /usr/local/bin/ckpmsg
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
RUN chmod +x /usr/local/bin/docker_entrypoint.sh \
&& mkdir -p /run/ckpool /var/log/ckpool /var/lib/kamado
EXPOSE 3333 8080
WORKDIR /root
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker_entrypoint.sh"]