77# * final: Creates the runtime image.
88
99ARG DEFAULT_TARGETPLATFORM="linux/amd64"
10- ARG BASE_DISTRO="debian:bullseye -slim"
10+ ARG BASE_DISTRO="debian:bookworm -slim"
1111
1212FROM --platform=$BUILDPLATFORM ${BASE_DISTRO} AS base-downloader
1313RUN set -ex \
@@ -76,7 +76,7 @@ RUN apt-get update -qq && \
7676 pkg-config \
7777 libssl-dev \
7878 protobuf-compiler \
79- python3.9 \
79+ python3 \
8080 python3-dev \
8181 python3-mako \
8282 python3-pip \
@@ -89,13 +89,13 @@ RUN apt-get update -qq && \
8989 unzip \
9090 tclsh
9191
92- ENV PATH="/root/.local/bin:$PATH"
93- ENV PYTHON_VERSION=3 \
94- PIP_BREAK_SYSTEM_PACKAGES=1
92+ ENV PATH="/root/.local/bin:$PATH" \
93+ PYTHON_VERSION=3
9594RUN curl -sSL https://install.python-poetry.org | python3 -
96- RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
97- RUN pip3 install --upgrade pip setuptools wheel
98- RUN poetry self add poetry-plugin-export
95+ RUN mkdir -p /root/.venvs && \
96+ python3 -m venv /root/.venvs/cln && \
97+ . /root/.venvs/cln/bin/activate && \
98+ pip3 install --upgrade pip setuptools wheel
9999
100100RUN wget -q https://zlib.net/fossils/zlib-1.2.13.tar.gz -O zlib.tar.gz && \
101101 wget -q https://www.sqlite.org/2019/sqlite-src-3290000.zip -O sqlite.zip && \
@@ -108,7 +108,11 @@ RUN git clone --recursive /tmp/lightning . && \
108108
109109# Do not build python plugins (clnrest & wss-proxy) here, python doesn't support cross compilation.
110110RUN sed -i '/^clnrest\| ^wss-proxy/d' pyproject.toml && poetry export -o requirements.txt --without-hashes
111- RUN pip3 install -r requirements.txt && pip3 cache purge
111+ RUN mkdir -p /root/.venvs && \
112+ python3 -m venv /root/.venvs/cln && \
113+ . /root/.venvs/cln/bin/activate && \
114+ pip3 install -r requirements.txt && \
115+ pip3 cache purge
112116WORKDIR /
113117
114118FROM base-builder AS base-builder-linux-amd64
@@ -257,21 +261,24 @@ RUN apt-get update -qq && \
257261 build-essential \
258262 libffi-dev \
259263 libssl-dev \
260- python3.9 \
264+ python3 \
261265 python3-dev \
262- python3-pip && \
266+ python3-pip \
267+ python3-venv && \
263268 apt-get clean && \
264269 rm -rf /var/lib/apt/lists/*
265270
266- ENV PYTHON_VERSION=3 \
267- PIP_BREAK_SYSTEM_PACKAGES=1
268- RUN pip3 install --upgrade pip setuptools wheel
271+ ENV PYTHON_VERSION=3
272+ RUN mkdir -p /root/.venvs && \
273+ python3 -m venv /root/.venvs/cln && \
274+ . /root/.venvs/cln/bin/activate && \
275+ pip3 install --upgrade pip setuptools wheel
269276
270277# Copy rustup_install_opts.txt file from builder
271278COPY --from=builder /tmp/rustup_install_opts.txt /tmp/rustup_install_opts.txt
272279# Setup ENV $RUSTUP_INSTALL_OPTS for this stage
273280RUN export $(cat /tmp/rustup_install_opts.txt)
274- ENV PATH="/root/.cargo/bin:$PATH"
281+ ENV PATH="/root/.cargo/bin:/root/.venvs/cln/bin: $PATH"
275282RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y ${RUSTUP_INSTALL_OPTS}
276283
277284WORKDIR /opt/lightningd/plugins/clnrest
@@ -315,7 +322,7 @@ RUN --mount=type=bind,from=builder,source=/var/libpq,target=/var/libpq,rw \
315322 ldconfig
316323
317324COPY --from=builder /tmp/lightning_install/ /usr/local/
318- COPY --from=builder-python /usr/local/ lib/python3.9/dist -packages/ /usr/local/lib/python3.9 /dist-packages/
325+ COPY --from=builder-python /root/.venvs/cln/ lib/python3.11/site -packages /usr/local/lib/python3.11 /dist-packages/
319326COPY --from=downloader /opt/bitcoin/bin /usr/bin
320327COPY --from=downloader /opt/litecoin/bin /usr/bin
321328COPY tools/docker-entrypoint.sh entrypoint.sh
0 commit comments