From c95d1bf51c02b216be9fd7a8064fb2215fbd630a Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Wed, 14 Aug 2024 14:37:48 -0700 Subject: [PATCH] docker: Fix for cryptography v42 upgrade Docker build for `linux/arm/v7` broke after recent cryptography update with PR https://github.com/ElementsProject/lightning/pull/7475. It maybe the root cause for PR https://github.com/ElementsProject/lightning/pull/7570 also. Changelog-Fixed: Fixes failing Docker build for `arm32` arch. --- Dockerfile | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2aab878cdc13..8f62da64a3fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -90,6 +90,7 @@ ENV PYTHON_VERSION=3 RUN curl -sSL https://install.python-poetry.org | python3 - RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 RUN pip3 install --upgrade pip setuptools wheel +ENV PATH="$PATH:/root/.local/bin" RUN wget -q https://zlib.net/fossils/zlib-1.2.13.tar.gz -O zlib.tar.gz && \ wget -q https://www.sqlite.org/2019/sqlite-src-3290000.zip -O sqlite.zip @@ -101,7 +102,7 @@ RUN git clone --recursive /tmp/lightning . && \ # 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 + poetry export -o requirements.txt --without-hashes RUN pip3 install -r requirements.txt && pip3 cache purge WORKDIR / @@ -178,6 +179,7 @@ RUN unzip sqlite.zip \ && make \ && make install && cd .. && rm sqlite.zip && rm -rf sqlite-* +ENV PATH="$PATH:/root/.local/bin" ENV RUST_PROFILE=release ENV PATH=$PATH:/root/.cargo/bin/ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y ${RUSTUP_INSTALL_OPTS} @@ -196,12 +198,12 @@ RUN ( ! [ "${target_host}" = "arm-linux-gnueabihf" ] ) || \ # Ensure that the desired grpcio-tools & protobuf versions are installed # https://github.com/ElementsProject/lightning/pull/7376#issuecomment-2161102381 -RUN /root/.local/bin/poetry lock --no-update && \ - /root/.local/bin/poetry install +RUN poetry lock --no-update && \ + poetry install RUN ./configure --prefix=/tmp/lightning_install --enable-static && \ make && \ - /root/.local/bin/poetry run make install + poetry run make install # We need to build python plugins on the target's arch because python doesn't support cross build FROM ${BASE_DISTRO} as builder-python @@ -222,9 +224,17 @@ RUN apt-get update -qq && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +# For cryptography v42 to build, we need to install latest cargo & rust (v1.80.1) +# Can't use apt install cargo rust because it installs v1.48.0 which is not compatible with cryptography v42 +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +RUN . $HOME/.cargo/env +RUN POETRY_VIRTUALENVS_CREATE=false pip install --upgrade cryptography==42.0.0 +RUN pip install --upgrade maturin + RUN curl -sSL https://install.python-poetry.org | python3 - RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 +ENV PATH="$PATH:/root/.local/bin" ENV PYTHON_VERSION=3 WORKDIR /opt/lightningd @@ -232,12 +242,12 @@ COPY plugins/clnrest/pyproject.toml plugins/clnrest/pyproject.toml COPY plugins/wss-proxy/pyproject.toml plugins/wss-proxy/pyproject.toml RUN cd plugins/clnrest && \ - /root/.local/bin/poetry export -o requirements.txt --without-hashes && \ + poetry export -o requirements.txt --without-hashes && \ pip3 install -r requirements.txt && \ cd /opt/lightningd RUN cd plugins/wss-proxy && \ - /root/.local/bin/poetry export -o requirements.txt --without-hashes && \ + poetry export -o requirements.txt --without-hashes && \ pip3 install -r requirements.txt && \ cd /opt/lightningd && \ pip3 cache purge