From 369c0c1391d1c28210cbc840dfeea4bb1b5b7bba Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 23 May 2024 08:34:11 +0900 Subject: [PATCH] Update Dockerfile and build-release.sh to PR7214 --- Dockerfile | 12 ++++++++---- tools/build-release.sh | 27 ++++++++++----------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7d878293e018..f99f24396331 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,6 +66,7 @@ RUN apt-get update -qq && \ gettext \ git \ gnupg \ + jq \ libpq-dev \ libtool \ libffi-dev \ @@ -98,8 +99,8 @@ COPY . /tmp/lightning RUN git clone --recursive /tmp/lightning . && \ git checkout $(git --work-tree=/tmp/lightning --git-dir=/tmp/lightning/.git rev-parse HEAD) -# Do not build clnrest here, since it's python, we can't cross compile it. -RUN sed -i '/^clnrest/d' pyproject.toml && \ +# Do not build python plugins (clnrest & wss-proxy) here, python doesn't support cross compilation. +RUN sed -i '/^clnrest\|^wss-proxy/d' pyproject.toml && \ /root/.local/bin/poetry export -o requirements.txt --without-hashes RUN pip3 install -r requirements.txt && pip3 cache purge WORKDIR / @@ -197,7 +198,7 @@ RUN ./configure --prefix=/tmp/lightning_install --enable-static && \ make && \ /root/.local/bin/poetry run make install -# We need to build cln-rest on the target's arch because python doesn't support cross build +# We need to build python plugins on the target's arch because python doesn't support cross build FROM ${BASE_DISTRO} as builder-python RUN apt-get update -qq && \ apt-get install -qq -y --no-install-recommends \ @@ -223,8 +224,11 @@ RUN rustup toolchain install stable --component rustfmt --allow-downgrade WORKDIR /opt/lightningd COPY plugins/clnrest/requirements.txt plugins/clnrest/requirements.txt +COPY plugins/wss-proxy/requirements.txt plugins/wss-proxy/requirements.txt ENV PYTHON_VERSION=3 -RUN pip3 install -r plugins/clnrest/requirements.txt && pip3 cache purge +RUN pip3 install -r plugins/clnrest/requirements.txt && \ + pip3 install -r plugins/wss-proxy/requirements.txt && \ + pip3 cache purge FROM ${BASE_DISTRO} as final diff --git a/tools/build-release.sh b/tools/build-release.sh index ed9953af9635..52122858259e 100755 --- a/tools/build-release.sh +++ b/tools/build-release.sh @@ -20,7 +20,6 @@ fi FORCE_UNCLEAN=false VERIFY_RELEASE=false -DOCKER_PUSH=false ALL_TARGETS="bin-Fedora-28-amd64 bin-Ubuntu docker sign" # ALL_TARGETS="bin-Fedora-28-amd64 bin-Ubuntu tarball deb docker sign" @@ -39,9 +38,6 @@ for arg; do --verify) VERIFY_RELEASE=true ;; - --push) - DOCKER_PUSH=true - ;; --help) echo "Usage: [--force-version=] [--force-unclean] [--force-mtime=YYYY-MM-DD] [--verify] [TARGETS]" echo Known targets: "$ALL_TARGETS" @@ -49,8 +45,8 @@ for arg; do echo "Example: tools/build-release.sh --force-version=v23.05 --force-unclean --force-mtime=2023-05-01 bin-Fedora-28-amd64 bin-Ubuntu sign" echo "Example: tools/build-release.sh --verify" echo "Example: tools/build-release.sh --force-version=v23.05 --force-unclean --force-mtime=2023-05-01 --verify" - echo "Example: tools/build-release.sh --push docker" - echo "Example: tools/build-release.sh --force-version=v23.05 --force-unclean --force-mtime=2023-05-01 --push docker" + echo "Example: tools/build-release.sh docker" + echo "Example: tools/build-release.sh --force-version=v23.05 --force-unclean --force-mtime=2023-05-01 docker" exit 0 ;; -*) @@ -176,21 +172,18 @@ if [ -z "${TARGETS##* docker *}" ]; then echo "Building Docker Images" DOCKER_USER="elementsproject" echo "Creating a multi-platform image tagged as $VERSION" - DOCKER_OPTS="--platform linux/amd64,linux/arm64,linux/arm/v7" - $DOCKER_PUSH && DOCKER_OPTS="$DOCKER_OPTS --push" + DOCKER_OPTS="--platform linux/amd64,linux/arm64,linux/arm/v7 --push" DOCKER_OPTS="$DOCKER_OPTS -t $DOCKER_USER/lightningd:$VERSION" DOCKER_OPTS="$DOCKER_OPTS -t $DOCKER_USER/lightningd:latest" - - #docker buildx create --use - - # shellcheck disable=SC2086 - docker buildx build $DOCKER_OPTS . - - if $DOCKER_PUSH; then - echo "Pushed a multi-platform image tagged as latest" + echo "Docker Options: $DOCKER_OPTS" + if sudo docker buildx ls | grep -q 'cln-builder'; then + sudo docker buildx use cln-builder else - echo "Docker Images Built. Ready to Upload on Dockerhub." + sudo docker buildx create --name=cln-builder --use fi + # shellcheck disable=SC2086 + sudo docker buildx build $DOCKER_OPTS . + echo "Pushed a multi-platform image tagged as latest" fi if [ -z "${TARGETS##* sign *}" ]; then