Skip to content

Commit

Permalink
docker: Fix for cryptography v42 upgrade
Browse files Browse the repository at this point in the history
Docker build for `linux/arm/v7` broke after recent cryptography update with PR #7475.

Maybe root cause for PR #7570.

Changelog-Fixed: Fixes failing Docker build for arm32 arch.
  • Loading branch information
ShahanaFarooqui committed Aug 14, 2024
1 parent b4ce524 commit 3dc83d5
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 /

Expand Down Expand Up @@ -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}
Expand All @@ -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
Expand All @@ -222,22 +224,30 @@ 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 source $HOME/.cargo/env
RUN POETRY_VIRTUALENVS_CREATE=false pip install --upgrade cryptography
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

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
Expand Down

0 comments on commit 3dc83d5

Please sign in to comment.