Skip to content

Commit

Permalink
Update Dockerfile and build-release.sh to PR7214
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier authored and endothermicdev committed May 23, 2024
1 parent 738ddc6 commit 369c0c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ RUN apt-get update -qq && \
gettext \
git \
gnupg \
jq \
libpq-dev \
libtool \
libffi-dev \
Expand Down Expand Up @@ -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 /
Expand Down Expand Up @@ -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 \
Expand All @@ -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

Expand Down
27 changes: 10 additions & 17 deletions tools/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -39,18 +38,15 @@ for arg; do
--verify)
VERIFY_RELEASE=true
;;
--push)
DOCKER_PUSH=true
;;
--help)
echo "Usage: [--force-version=<ver>] [--force-unclean] [--force-mtime=YYYY-MM-DD] [--verify] [TARGETS]"
echo Known targets: "$ALL_TARGETS"
echo "Example: tools/build-release.sh"
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
;;
-*)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 369c0c1

Please sign in to comment.