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. It maybe the root cause for PR #7570 also.

Changelog-Fixed: Fixes failing Docker build for `arm32` arch.
  • Loading branch information
ShahanaFarooqui committed Aug 14, 2024
1 parent b8bc637 commit c7f667b
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 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,31 @@ RUN apt-get update -qq && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Building wheel for cryptography v42, we need to install latest cargo & rust (v1.80.1)
# Can't use `apt install cargo rust` because it installs v1.48.0
# but cryptography requires Rust >=1.63.0.
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN PATH="$HOME/.cargo/bin:$PATH" && rustc --version && cargo --version
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

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 c7f667b

Please sign in to comment.