pyblock/dockerfile

99 lines
4 KiB
Text
Raw Permalink Normal View History

FROM ubuntu:24.04
2022-12-29 01:14:41 +01:00
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PYBLOCK_PORT=6969
2022-12-29 01:14:41 +01:00
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git libjson-c-dev libwebsockets-dev \
python3 python3-pip python3-venv \
curl jq wget \
2022-12-29 01:14:41 +01:00
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Pin ttyd to a specific release tag for reproducibility
RUN git clone --branch 1.7.7 --depth 1 https://github.com/tsl0922/ttyd.git \
2022-12-29 01:14:41 +01:00
&& cd ttyd \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make \
&& make install \
&& cd /app && rm -rf ttyd
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3-dev libgmp-dev libffi-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install bitcoin-cli (Bitcoin Knots, not Core — same RPC protocol, different
# project) and lncli so PyBLOCK's mode A/B can talk to Umbrel's Bitcoin and
# LND containers over RPC/gRPC without a degraded Lite Mode fallback. The
# binaries are wrapped by umbrel/{bitcoin-cli,lncli}-wrapper.sh (installed
# below) which inject the connection details Umbrel injects via env vars.
fix(umbrel): bundle bitcoin-cli and lncli for mode A/B without Lite fallback PyBLOCK's mode A (Bitcoin + Lightning) and mode B (Bitcoin only) call bitcoin-cli and lncli directly via subprocess. The Umbrel image did not ship those binaries, so the startup validation in PyBlock.py:1898-1909 detected the empty CLI paths and silently redirected to Lite Mode against public APIs — defeating the point of installing PyBLOCK on a node. Per nmfretz's review on getumbrel/umbrel-apps#5258, this takes the "bundle the binaries inside the PyBLOCK image" path (option 2): - dockerfile: download bitcoin-cli (Bitcoin Core 28.1) and lncli (LND v0.20.1-beta, matching what Umbrel ships) for both linux/amd64 and linux/arm64. Verifies the Bitcoin Core SHA256SUMS. Real binaries land at /usr/local/bin/{bitcoin-cli,lncli}.bin. - umbrel/{bitcoin-cli,lncli}-wrapper.sh: thin shell wrappers installed as /usr/local/bin/{bitcoin-cli,lncli} that exec the real binary with -rpcconnect/-rpcuser/-rpcpassword (or --rpcserver/--tlscertpath/ --macaroonpath for lncli) injected from the BITCOIN_RPC_* / LND_* env vars Umbrel provides via APP_BITCOIN_* / APP_LIGHTNING_*. They fail loud if those env vars are missing. - entrypoint.sh: default BITCOIN_CLI_PATH/LND_CLI_PATH to the wrapper locations when the relevant RPC host env vars are set and the wrapper is executable, so bclock.conf / blndconnect.conf get the right bitcoincli / ln paths automatically. - umbrel/: bump image tag and app version to v4.0.2 with release notes. Local smoke test on amd64: bitcoin-cli.bin --version -> Bitcoin Core RPC client version v28.1.0 lncli.bin --version -> lncli version 0.20.1-beta /usr/local/bin/bitcoin-cli (no env) -> fails with "BITCOIN_RPC_HOST must be set" /usr/local/bin/bitcoin-cli (env set) -> dispatches to the real binary Image grows ~70MB (mostly the Go-built lncli). Co-Authored-By: kulvex code <noreply@github.com>
2026-06-23 18:10:00 -03:00
ARG TARGETARCH
ARG KNOTS_VERSION=28.1.knots20250305
ARG KNOTS_SERIES=28.x
fix(umbrel): bundle bitcoin-cli and lncli for mode A/B without Lite fallback PyBLOCK's mode A (Bitcoin + Lightning) and mode B (Bitcoin only) call bitcoin-cli and lncli directly via subprocess. The Umbrel image did not ship those binaries, so the startup validation in PyBlock.py:1898-1909 detected the empty CLI paths and silently redirected to Lite Mode against public APIs — defeating the point of installing PyBLOCK on a node. Per nmfretz's review on getumbrel/umbrel-apps#5258, this takes the "bundle the binaries inside the PyBLOCK image" path (option 2): - dockerfile: download bitcoin-cli (Bitcoin Core 28.1) and lncli (LND v0.20.1-beta, matching what Umbrel ships) for both linux/amd64 and linux/arm64. Verifies the Bitcoin Core SHA256SUMS. Real binaries land at /usr/local/bin/{bitcoin-cli,lncli}.bin. - umbrel/{bitcoin-cli,lncli}-wrapper.sh: thin shell wrappers installed as /usr/local/bin/{bitcoin-cli,lncli} that exec the real binary with -rpcconnect/-rpcuser/-rpcpassword (or --rpcserver/--tlscertpath/ --macaroonpath for lncli) injected from the BITCOIN_RPC_* / LND_* env vars Umbrel provides via APP_BITCOIN_* / APP_LIGHTNING_*. They fail loud if those env vars are missing. - entrypoint.sh: default BITCOIN_CLI_PATH/LND_CLI_PATH to the wrapper locations when the relevant RPC host env vars are set and the wrapper is executable, so bclock.conf / blndconnect.conf get the right bitcoincli / ln paths automatically. - umbrel/: bump image tag and app version to v4.0.2 with release notes. Local smoke test on amd64: bitcoin-cli.bin --version -> Bitcoin Core RPC client version v28.1.0 lncli.bin --version -> lncli version 0.20.1-beta /usr/local/bin/bitcoin-cli (no env) -> fails with "BITCOIN_RPC_HOST must be set" /usr/local/bin/bitcoin-cli (env set) -> dispatches to the real binary Image grows ~70MB (mostly the Go-built lncli). Co-Authored-By: kulvex code <noreply@github.com>
2026-06-23 18:10:00 -03:00
ARG LND_VERSION=v0.20.1-beta
RUN set -eux; \
case "${TARGETARCH}" in \
amd64) BTC_ARCH=x86_64-linux-gnu; LND_ARCH=amd64 ;; \
arm64) BTC_ARCH=aarch64-linux-gnu; LND_ARCH=arm64 ;; \
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \
esac; \
cd /tmp; \
wget -q "https://bitcoinknots.org/files/${KNOTS_SERIES}/${KNOTS_VERSION}/bitcoin-${KNOTS_VERSION}-${BTC_ARCH}.tar.gz"; \
wget -q "https://bitcoinknots.org/files/${KNOTS_SERIES}/${KNOTS_VERSION}/SHA256SUMS"; \
grep "bitcoin-${KNOTS_VERSION}-${BTC_ARCH}.tar.gz" SHA256SUMS | sha256sum -c -; \
tar -xzf "bitcoin-${KNOTS_VERSION}-${BTC_ARCH}.tar.gz" "bitcoin-${KNOTS_VERSION}/bin/bitcoin-cli"; \
install -m 0755 "bitcoin-${KNOTS_VERSION}/bin/bitcoin-cli" /usr/local/bin/bitcoin-cli.bin; \
rm -rf "bitcoin-${KNOTS_VERSION}" "bitcoin-${KNOTS_VERSION}-${BTC_ARCH}.tar.gz" SHA256SUMS; \
fix(umbrel): bundle bitcoin-cli and lncli for mode A/B without Lite fallback PyBLOCK's mode A (Bitcoin + Lightning) and mode B (Bitcoin only) call bitcoin-cli and lncli directly via subprocess. The Umbrel image did not ship those binaries, so the startup validation in PyBlock.py:1898-1909 detected the empty CLI paths and silently redirected to Lite Mode against public APIs — defeating the point of installing PyBLOCK on a node. Per nmfretz's review on getumbrel/umbrel-apps#5258, this takes the "bundle the binaries inside the PyBLOCK image" path (option 2): - dockerfile: download bitcoin-cli (Bitcoin Core 28.1) and lncli (LND v0.20.1-beta, matching what Umbrel ships) for both linux/amd64 and linux/arm64. Verifies the Bitcoin Core SHA256SUMS. Real binaries land at /usr/local/bin/{bitcoin-cli,lncli}.bin. - umbrel/{bitcoin-cli,lncli}-wrapper.sh: thin shell wrappers installed as /usr/local/bin/{bitcoin-cli,lncli} that exec the real binary with -rpcconnect/-rpcuser/-rpcpassword (or --rpcserver/--tlscertpath/ --macaroonpath for lncli) injected from the BITCOIN_RPC_* / LND_* env vars Umbrel provides via APP_BITCOIN_* / APP_LIGHTNING_*. They fail loud if those env vars are missing. - entrypoint.sh: default BITCOIN_CLI_PATH/LND_CLI_PATH to the wrapper locations when the relevant RPC host env vars are set and the wrapper is executable, so bclock.conf / blndconnect.conf get the right bitcoincli / ln paths automatically. - umbrel/: bump image tag and app version to v4.0.2 with release notes. Local smoke test on amd64: bitcoin-cli.bin --version -> Bitcoin Core RPC client version v28.1.0 lncli.bin --version -> lncli version 0.20.1-beta /usr/local/bin/bitcoin-cli (no env) -> fails with "BITCOIN_RPC_HOST must be set" /usr/local/bin/bitcoin-cli (env set) -> dispatches to the real binary Image grows ~70MB (mostly the Go-built lncli). Co-Authored-By: kulvex code <noreply@github.com>
2026-06-23 18:10:00 -03:00
wget -q "https://github.com/lightningnetwork/lnd/releases/download/${LND_VERSION}/lnd-linux-${LND_ARCH}-${LND_VERSION}.tar.gz"; \
tar -xzf "lnd-linux-${LND_ARCH}-${LND_VERSION}.tar.gz" --strip-components=1 "lnd-linux-${LND_ARCH}-${LND_VERSION}/lncli"; \
install -m 0755 lncli /usr/local/bin/lncli.bin; \
rm -f lncli "lnd-linux-${LND_ARCH}-${LND_VERSION}.tar.gz"
RUN python3 -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
# Copy project files
COPY requirements.txt /app/pyblock/requirements.txt
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r /app/pyblock/requirements.txt
COPY . /app/pyblock/
fix(umbrel): bundle bitcoin-cli and lncli for mode A/B without Lite fallback PyBLOCK's mode A (Bitcoin + Lightning) and mode B (Bitcoin only) call bitcoin-cli and lncli directly via subprocess. The Umbrel image did not ship those binaries, so the startup validation in PyBlock.py:1898-1909 detected the empty CLI paths and silently redirected to Lite Mode against public APIs — defeating the point of installing PyBLOCK on a node. Per nmfretz's review on getumbrel/umbrel-apps#5258, this takes the "bundle the binaries inside the PyBLOCK image" path (option 2): - dockerfile: download bitcoin-cli (Bitcoin Core 28.1) and lncli (LND v0.20.1-beta, matching what Umbrel ships) for both linux/amd64 and linux/arm64. Verifies the Bitcoin Core SHA256SUMS. Real binaries land at /usr/local/bin/{bitcoin-cli,lncli}.bin. - umbrel/{bitcoin-cli,lncli}-wrapper.sh: thin shell wrappers installed as /usr/local/bin/{bitcoin-cli,lncli} that exec the real binary with -rpcconnect/-rpcuser/-rpcpassword (or --rpcserver/--tlscertpath/ --macaroonpath for lncli) injected from the BITCOIN_RPC_* / LND_* env vars Umbrel provides via APP_BITCOIN_* / APP_LIGHTNING_*. They fail loud if those env vars are missing. - entrypoint.sh: default BITCOIN_CLI_PATH/LND_CLI_PATH to the wrapper locations when the relevant RPC host env vars are set and the wrapper is executable, so bclock.conf / blndconnect.conf get the right bitcoincli / ln paths automatically. - umbrel/: bump image tag and app version to v4.0.2 with release notes. Local smoke test on amd64: bitcoin-cli.bin --version -> Bitcoin Core RPC client version v28.1.0 lncli.bin --version -> lncli version 0.20.1-beta /usr/local/bin/bitcoin-cli (no env) -> fails with "BITCOIN_RPC_HOST must be set" /usr/local/bin/bitcoin-cli (env set) -> dispatches to the real binary Image grows ~70MB (mostly the Go-built lncli). Co-Authored-By: kulvex code <noreply@github.com>
2026-06-23 18:10:00 -03:00
# Install the bitcoin-cli / lncli wrappers as the default CLI paths so any
# subprocess call to bitcoin-cli / lncli (including PyBLOCK's mode A/B menus)
# is transparently routed through RPC/gRPC against the Umbrel dependency
# containers. The real binaries live at /usr/local/bin/{bitcoin-cli,lncli}.bin.
RUN install -m 0755 /app/pyblock/umbrel/bitcoin-cli-wrapper.sh /usr/local/bin/bitcoin-cli \
&& install -m 0755 /app/pyblock/umbrel/lncli-wrapper.sh /usr/local/bin/lncli
# Entrypoint for auto-configuration
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Create config volume mount point
RUN mkdir -p /app/pyblock/pybitblock/config
# Pin pyblock to UID/GID 1000 so it matches the user Umbrel forces via
# `user: "1000:1000"` in docker-compose. The base ubuntu:24.04 image ships an
# `ubuntu` user already at 1000, so remove it first to free the UID.
RUN userdel -r ubuntu 2>/dev/null || true \
&& groupadd -g 1000 pyblock \
&& useradd -m -s /bin/bash -u 1000 -g 1000 pyblock \
&& chown -R pyblock:pyblock /app
USER pyblock
EXPOSE 6969
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:${PYBLOCK_PORT:-6969}/ || exit 1
ENTRYPOINT ["/app/entrypoint.sh"]