Adapt Dockerfile for BTCPay deployment
Some checks failed
Docker packaging / main (push) Has been cancelled
Some checks failed
Docker packaging / main (push) Has been cancelled
This commit is contained in:
parent
2b8b709bfd
commit
d94b9a2713
34
.github/workflows/docker.yml
vendored
Normal file
34
.github/workflows/docker.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
name: Docker packaging
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'basedon-*'
|
||||
|
||||
jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
-
|
||||
name: Environment variables
|
||||
run: env
|
||||
-
|
||||
name: Create images
|
||||
env:
|
||||
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
|
||||
DOCKERHUB_PASS: ${{ secrets.DOCKERHUB_PASS }}
|
||||
DOCKERHUB_REPO: ${{ vars.DOCKERHUB_REPO }}
|
||||
shell: bash
|
||||
run: |
|
||||
LATEST_TAG=${GITHUB_REF#refs/tags/}
|
||||
LATEST_TAG=${LATEST_TAG:8} #trim "basedon-" from tag
|
||||
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USER" --password-stdin
|
||||
docker buildx create --use
|
||||
DOCKER_BUILDX_OPTS="--platform linux/amd64,linux/arm64,linux/arm/v7 --push"
|
||||
docker buildx build $DOCKER_BUILDX_OPTS -t $DOCKERHUB_REPO:$LATEST_TAG .
|
||||
18
Dockerfile
18
Dockerfile
@ -16,12 +16,18 @@ RUN set -ex \
|
||||
|
||||
FROM base-downloader AS base-downloader-linux-amd64
|
||||
ENV TARBALL_ARCH_FINAL=x86_64-linux-gnu
|
||||
ENV DESCHASHPLUGIN_ARCH=linux-amd64
|
||||
ENV DESCHASHPLUGIN_HASH=deadc00c68fac80b2718d92f69bf06acd8fff646228d497bbb76a4f0a12ca217
|
||||
|
||||
FROM base-downloader AS base-downloader-linux-arm64
|
||||
ENV TARBALL_ARCH_FINAL=aarch64-linux-gnu
|
||||
ENV DESCHASHPLUGIN_ARCH=linux-arm64
|
||||
ENV DESCHASHPLUGIN_HASH=d48c3e5aede77bd9cb72d78689ce12c0327f624435cb0496b3eacb92df416363
|
||||
|
||||
FROM base-downloader AS base-downloader-linux-arm
|
||||
ENV TARBALL_ARCH_FINAL=arm-linux-gnueabihf
|
||||
ENV DESCHASHPLUGIN_ARCH=linux-arm
|
||||
ENV DESCHASHPLUGIN_HASH=f7df336c72dd1674bd18ff23862a410b6a9691a3e13752264dcffa0950e21c74
|
||||
|
||||
FROM base-downloader-${TARGETOS}-${TARGETARCH} AS downloader
|
||||
|
||||
@ -55,6 +61,14 @@ RUN mkdir /opt/litecoin && cd /opt/litecoin \
|
||||
&& tar -xzvf litecoin.tar.gz litecoin-$LITECOIN_VERSION/bin/litecoin-cli --strip-components=1 --exclude=*-qt \
|
||||
&& rm litecoin.tar.gz
|
||||
|
||||
ENV DESCHASHPLUGIN_URL https://github.com/nbd-wtf/invoicewithdescriptionhash/releases/download/v1.4/invoicewithdescriptionhash-v1.4-${DESCHASHPLUGIN_ARCH}.tar.gz
|
||||
ENV DESCHASHPLUGIN_SHA256 ${DESCHASHPLUGIN_HASH}
|
||||
RUN mkdir /opt/deschashplugin && cd /opt/deschashplugin \
|
||||
&& wget -qO invoicewithdescriptionhash.tar.gz "$DESCHASHPLUGIN_URL" \
|
||||
&& echo "$DESCHASHPLUGIN_SHA256 invoicewithdescriptionhash.tar.gz" | sha256sum -c - \
|
||||
&& tar -xzvf invoicewithdescriptionhash.tar.gz && rm invoicewithdescriptionhash.tar.gz \
|
||||
&& chmod a+x invoicewithdescriptionhash
|
||||
|
||||
FROM --platform=${DEFAULT_TARGETPLATFORM} ${BASE_DISTRO} AS base-builder
|
||||
RUN apt-get update -qq && \
|
||||
apt-get install -qq -y --no-install-recommends \
|
||||
@ -307,6 +321,8 @@ ENV LIGHTNINGD_DATA=/root/.lightning \
|
||||
LIGHTNINGD_NETWORK=bitcoin
|
||||
|
||||
RUN mkdir $LIGHTNINGD_DATA && \
|
||||
mkdir /etc/bundledplugins && \
|
||||
mkdir $LIGHTNINGD_DATA/plugins && \
|
||||
touch $LIGHTNINGD_DATA/config
|
||||
VOLUME [ "/root/.lightning" ]
|
||||
|
||||
@ -321,6 +337,8 @@ COPY --from=builder /tmp/lightning_install/ /usr/local/
|
||||
COPY --from=builder-python /root/.venvs/cln/lib/python3.11/site-packages /usr/local/lib/python3.11/dist-packages/
|
||||
COPY --from=downloader /opt/bitcoin/bin /usr/bin
|
||||
COPY --from=downloader /opt/litecoin/bin /usr/bin
|
||||
COPY --from=downloader /opt/deschashplugin $LIGHTNINGD_DATA/plugins
|
||||
COPY --from=downloader /opt/deschashplugin /etc/bundledplugins
|
||||
COPY tools/docker-entrypoint.sh entrypoint.sh
|
||||
|
||||
EXPOSE 9735 9835
|
||||
|
||||
@ -1048,6 +1048,7 @@ static void wait_and_check_bitcoind(struct plugin *p)
|
||||
pid_t child;
|
||||
const char **cmd = gather_args(bitcoind, "getnetworkinfo", NULL);
|
||||
bool printed = false;
|
||||
bool isWarmup = false;
|
||||
char *output = NULL;
|
||||
|
||||
for (;;) {
|
||||
@ -1083,17 +1084,20 @@ static void wait_and_check_bitcoind(struct plugin *p)
|
||||
/* bitcoin/src/rpc/protocol.h:
|
||||
* RPC_IN_WARMUP = -28, //!< Client still warming up
|
||||
*/
|
||||
if (WEXITSTATUS(status) != 28) {
|
||||
if (WEXITSTATUS(status) == 1)
|
||||
bitcoind_failure(p, "Could not connect to bitcoind using"
|
||||
" bitcoin-cli. Is bitcoind running?");
|
||||
bitcoind_failure(p, tal_fmt(bitcoind, "%s exited with code %i: %s",
|
||||
cmd[0], WEXITSTATUS(status), output));
|
||||
}
|
||||
isWarmup = WEXITSTATUS(status) == 28;
|
||||
|
||||
if (!printed) {
|
||||
plugin_log(p, LOG_UNUSUAL,
|
||||
"Waiting for bitcoind to warm up...");
|
||||
if (isWarmup)
|
||||
{
|
||||
plugin_log(p, LOG_UNUSUAL,
|
||||
"Waiting for bitcoind to warm up...");
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin_log(p, LOG_UNUSUAL,
|
||||
tal_fmt(bitcoind, "%s exited with code %i: %s... retrying",
|
||||
cmd[0], WEXITSTATUS(status), output));
|
||||
}
|
||||
printed = true;
|
||||
}
|
||||
sleep(1);
|
||||
|
||||
@ -2,19 +2,77 @@
|
||||
|
||||
: "${EXPOSE_TCP:=false}"
|
||||
|
||||
networkdatadir="${LIGHTNINGD_DATA}/${LIGHTNINGD_NETWORK}"
|
||||
cat <<-EOF > "$LIGHTNINGD_DATA/config"
|
||||
${LIGHTNINGD_OPT}
|
||||
bind-addr=0.0.0.0:${LIGHTNINGD_PORT}
|
||||
EOF
|
||||
|
||||
LIGHTNINGD_NETWORK_NAME=""
|
||||
|
||||
if [ "$LIGHTNINGD_CHAIN" == "btc" ] && [ "$LIGHTNINGD_NETWORK" == "mainnet" ]; then
|
||||
LIGHTNINGD_NETWORK_NAME="bitcoin"
|
||||
elif [ "$LIGHTNINGD_CHAIN" == "btc" ] && [ "$LIGHTNINGD_NETWORK" == "testnet" ]; then
|
||||
LIGHTNINGD_NETWORK_NAME="testnet"
|
||||
elif [ "$LIGHTNINGD_CHAIN" == "btc" ] && [ "$LIGHTNINGD_NETWORK" == "regtest" ]; then
|
||||
LIGHTNINGD_NETWORK_NAME="regtest"
|
||||
elif [ "$LIGHTNINGD_CHAIN" == "ltc" ] && [ "$LIGHTNINGD_NETWORK" == "mainnet" ]; then
|
||||
LIGHTNINGD_NETWORK_NAME="litecoin"
|
||||
elif [ "$LIGHTNINGD_CHAIN" == "ltc" ] && [ "$LIGHTNINGD_NETWORK" == "testnet" ]; then
|
||||
LIGHTNINGD_NETWORK_NAME="litecoin-testnet"
|
||||
else
|
||||
echo "Invalid combinaison of LIGHTNINGD_NETWORK and LIGHTNINGD_CHAIN. LIGHTNINGD_CHAIN should be btc or ltc. LIGHTNINGD_NETWORK should be mainnet, testnet or regtest."
|
||||
echo "ltc regtest is not supported"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "network=$LIGHTNINGD_NETWORK_NAME" >> "$LIGHTNINGD_DATA/config"
|
||||
echo "network=$LIGHTNINGD_NETWORK_NAME added in $LIGHTNINGD_DATA/config"
|
||||
|
||||
if [[ "${LIGHTNINGD_ANNOUNCEADDR}" ]]; then
|
||||
echo "announce-addr=$LIGHTNINGD_ANNOUNCEADDR:${LIGHTNINGD_PORT}" >> "$LIGHTNINGD_DATA/config"
|
||||
fi
|
||||
|
||||
if [[ "${LIGHTNINGD_ALIAS}" ]]; then
|
||||
# This allow to strip this parameter if LND_ALIGHTNINGD_ALIASLIAS is empty or null, and truncate it
|
||||
LIGHTNINGD_ALIAS="$(echo "$LIGHTNINGD_ALIAS" | cut -c -32)"
|
||||
echo "alias=$LIGHTNINGD_ALIAS" >> "$LIGHTNINGD_DATA/config"
|
||||
echo "alias=$LIGHTNINGD_ALIAS added to $LIGHTNINGD_DATA/config"
|
||||
fi
|
||||
|
||||
if [[ "${LIGHTNINGD_READY_FILE}" ]]; then
|
||||
echo "Waiting $LIGHTNINGD_READY_FILE to be created..."
|
||||
while [ ! -f "$LIGHTNINGD_READY_FILE" ]; do sleep 1; done
|
||||
echo "The chain is fully synched"
|
||||
fi
|
||||
|
||||
if [[ "${LIGHTNINGD_HIDDENSERVICE_HOSTNAME_FILE}" ]]; then
|
||||
echo "Waiting $LIGHTNINGD_HIDDENSERVICE_HOSTNAME_FILE to be created by tor..."
|
||||
while [ ! -f "$LIGHTNINGD_HIDDENSERVICE_HOSTNAME_FILE" ]; do sleep 1; done
|
||||
HIDDENSERVICE_ONION="$(head -n 1 "$LIGHTNINGD_HIDDENSERVICE_HOSTNAME_FILE"):${LIGHTNINGD_PORT}"
|
||||
echo "announce-addr=$HIDDENSERVICE_ONION" >> "$LIGHTNINGD_DATA/config"
|
||||
echo "announce-addr=$HIDDENSERVICE_ONION added to $LIGHTNINGD_DATA/config"
|
||||
fi
|
||||
|
||||
if ! grep -q "^rpc-file=" "$LIGHTNINGD_DATA/config"; then
|
||||
echo "rpc-file=$LIGHTNINGD_DATA/lightning-rpc" >> "$LIGHTNINGD_DATA/config"
|
||||
echo "rpc-file=$LIGHTNINGD_DATA/lightning-rpc added to $LIGHTNINGD_DATA/config"
|
||||
fi
|
||||
|
||||
echo "Installing bundled plugins"
|
||||
mkdir -p "$LIGHTNINGD_DATA/plugins"
|
||||
cp -u /etc/bundledplugins/* $LIGHTNINGD_DATA/plugins/
|
||||
|
||||
set -m
|
||||
lightningd --network="${LIGHTNINGD_NETWORK}" "$@" &
|
||||
lightningd "$@" &
|
||||
|
||||
echo "Core-Lightning starting"
|
||||
while read -r i; do if [ "$i" = "lightning-rpc" ]; then break; fi; done \
|
||||
< <(inotifywait -e create,open --format '%f' --quiet "${networkdatadir}" --monitor)
|
||||
< <(inotifywait -e create,open --format '%f' --quiet "$LIGHTNINGD_DATA" --monitor)
|
||||
|
||||
if [ "$EXPOSE_TCP" == "true" ]; then
|
||||
echo "Core-Lightning started, RPC available on port $LIGHTNINGD_RPC_PORT"
|
||||
|
||||
socat "TCP4-listen:$LIGHTNINGD_RPC_PORT,fork,reuseaddr" "UNIX-CONNECT:${networkdatadir}/lightning-rpc" &
|
||||
socat "TCP4-listen:$LIGHTNINGD_RPC_PORT,fork,reuseaddr" "UNIX-CONNECT:$LIGHTNINGD_DATA/lightning-rpc" &
|
||||
fi
|
||||
|
||||
# Now run any scripts which exist in the lightning-poststart.d directory
|
||||
@ -24,4 +82,36 @@ if [ -d "$LIGHTNINGD_DATA"/lightning-poststart.d ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
RUNE_PATH="$LIGHTNINGD_DATA/rune.env"
|
||||
if [ -f "$RUNE_PATH" ]; then
|
||||
source "$RUNE_PATH"
|
||||
matches=$(lightning-cli showrunes | jq --arg rune "$LIGHTNING_RUNE" --arg unique_id "$UNIQUE_ID" \
|
||||
'.runes[] | select(.rune == $rune and .unique_id == $unique_id)')
|
||||
if [[ -n $matches ]]; then
|
||||
echo "Rune already created"
|
||||
else
|
||||
LIGHTNING_RUNE=""
|
||||
UNIQUE_ID=""
|
||||
echo "Rune not found, re-creating..."
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! [[ "$LIGHTNING_RUNE" ]]; then
|
||||
echo "Creating rune..."
|
||||
RUNE_RESPONSE=$(lightning-cli createrune 'restrictions=[["For Applications#"]]')
|
||||
LIGHTNING_RUNE=$(echo "$RUNE_RESPONSE" | jq -r '.rune')
|
||||
UNIQUE_ID=$(echo "$RUNE_RESPONSE" | jq -r '.unique_id')
|
||||
if [[ "$LIGHTNING_RUNE" ]]; then
|
||||
echo "LIGHTNING_RUNE=\"${LIGHTNING_RUNE}\"" > "$RUNE_PATH"
|
||||
echo "UNIQUE_ID=${UNIQUE_ID}" >> "$RUNE_PATH"
|
||||
echo "Rune created"
|
||||
source "$RUNE_PATH"
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! [[ "$LIGHTNING_RUNE" ]]; then
|
||||
echo "Error while creating a rune..."
|
||||
echo "$RUNE_RESPONSE"
|
||||
fi
|
||||
|
||||
fg %-
|
||||
|
||||
Loading…
Reference in New Issue
Block a user