@@ -60,15 +60,17 @@ RUN apt-get update -qq && \
6060 apt-get install -qq -y --no-install-recommends \
6161 autoconf \
6262 automake \
63+ bison \
6364 build-essential \
6465 ca-certificates \
6566 curl \
6667 dirmngr \
68+ flex \
6769 gettext \
6870 git \
6971 gnupg \
7072 jq \
71- libpq -dev \
73+ libicu -dev \
7274 libtool \
7375 libffi-dev \
7476 pkg-config \
@@ -88,14 +90,15 @@ RUN apt-get update -qq && \
8890 tclsh
8991
9092ENV PATH="/root/.local/bin:$PATH"
91- ENV PYTHON_VERSION=3
93+ ENV PYTHON_VERSION=3 \
94+ PIP_BREAK_SYSTEM_PACKAGES=1
9295RUN curl -sSL https://install.python-poetry.org | python3 -
9396RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
9497RUN pip3 install --upgrade pip setuptools wheel
9598RUN poetry self add poetry-plugin-export
9699
97100RUN wget -q https://zlib.net/fossils/zlib-1.2.13.tar.gz -O zlib.tar.gz && \
98- wget -q https://www.sqlite.org/2019/sqlite-src-3290000.zip -O sqlite.zip \
101+ wget -q https://www.sqlite.org/2019/sqlite-src-3290000.zip -O sqlite.zip && \
99102 wget -q https://ftp.postgresql.org/pub/source/v17.1/postgresql-17.1.tar.gz -O postgres.tar.gz
100103
101104WORKDIR /opt/lightningd
@@ -110,6 +113,9 @@ WORKDIR /
110113
111114FROM base-builder AS base-builder-linux-amd64
112115
116+ ENV POSTGRES_CONFIG="--without-readline" \
117+ PG_CONFIG=/usr/local/pgsql/bin/pg_config
118+
113119FROM base-builder AS base-builder-linux-arm64
114120ENV target_host=aarch64-linux-gnu \
115121 target_host_rust=aarch64-unknown-linux-gnu \
@@ -130,12 +136,13 @@ QEMU_LD_PREFIX=/usr/${target_host} \
130136HOST=${target_host} \
131137TARGET=${target_host_rust} \
132138RUSTUP_INSTALL_OPTS="--target ${target_host_rust} --default-host ${target_host_rust}" \
133- PKG_CONFIG_PATH="/usr/${target_host}/lib/pkgconfig" \
134- PG_CONFIG_PATH="/usr/${target_host}/bin/pg_config"
139+ PKG_CONFIG_PATH="/usr/${target_host}/lib/pkgconfig"
135140
136141ENV \
137142ZLIB_CONFIG="--prefix=${QEMU_LD_PREFIX}" \
138- SQLITE_CONFIG="--host=${target_host} --prefix=$QEMU_LD_PREFIX"
143+ SQLITE_CONFIG="--host=${target_host} --prefix=${QEMU_LD_PREFIX}" \
144+ POSTGRES_CONFIG="--without-readline --prefix=${QEMU_LD_PREFIX}" \
145+ PG_CONFIG="${QEMU_LD_PREFIX}/bin/pg_config"
139146
140147FROM base-builder AS base-builder-linux-arm
141148
@@ -158,13 +165,13 @@ QEMU_LD_PREFIX=/usr/${target_host} \
158165HOST=${target_host} \
159166TARGET=${target_host_rust} \
160167RUSTUP_INSTALL_OPTS="--target ${target_host_rust} --default-host ${target_host_rust}" \
161- PKG_CONFIG_PATH="/usr/${target_host}/lib/pkgconfig" \
162- PG_CONFIG_PATH="/usr/${target_host}/bin/pg_config"
168+ PKG_CONFIG_PATH="/usr/${target_host}/lib/pkgconfig"
163169
164170ENV \
165171ZLIB_CONFIG="--prefix=${QEMU_LD_PREFIX}" \
166- SQLITE_CONFIG="--host=${target_host} --prefix=$QEMU_LD_PREFIX" \
167- POSTGRES_CONFIG="--without-readline --prefix=${QEMU_LD_PREFIX}"
172+ SQLITE_CONFIG="--host=${target_host} --prefix=${QEMU_LD_PREFIX}" \
173+ POSTGRES_CONFIG="--without-readline --prefix=${QEMU_LD_PREFIX}" \
174+ PG_CONFIG="${QEMU_LD_PREFIX}/bin/pg_config"
168175
169176FROM base-builder-${TARGETOS}-${TARGETARCH} AS builder
170177
@@ -198,6 +205,9 @@ RUN mkdir postgres && tar xvf postgres.tar.gz -C postgres --strip-components=1 \
198205 rm -rf postgres && \
199206 ldconfig "$(${PG_CONFIG} --libdir)"
200207
208+ # Save libpq to a specific location to copy it into the final image.
209+ RUN mkdir /var/libpq && cp -a "$(${PG_CONFIG} --libdir)" /libpq.* /var/libpq
210+
201211ENV RUST_PROFILE=release
202212ENV PATH="/root/.cargo/bin:/root/.local/bin:$PATH"
203213RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y ${RUSTUP_INSTALL_OPTS}
@@ -253,8 +263,8 @@ RUN apt-get update -qq && \
253263 apt-get clean && \
254264 rm -rf /var/lib/apt/lists/*
255265
256- RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
257- ENV PYTHON_VERSION=3
266+ ENV PYTHON_VERSION=3 \
267+ PIP_BREAK_SYSTEM_PACKAGES=1
258268RUN pip3 install --upgrade pip setuptools wheel
259269
260270# Copy rustup_install_opts.txt file from builder
@@ -283,9 +293,8 @@ RUN apt-get update && \
283293 socat \
284294 inotify-tools \
285295 jq \
286- python3.9 \
287- python3-pip \
288- libpq5 && \
296+ python3 \
297+ python3-pip && \
289298 apt-get clean && \
290299 rm -rf /var/lib/apt/lists/*
291300
@@ -298,6 +307,13 @@ RUN mkdir $LIGHTNINGD_DATA && \
298307 touch $LIGHTNINGD_DATA/config
299308VOLUME [ "/root/.lightning" ]
300309
310+ # Take libpq directly from builder.
311+ RUN mkdir /var/libpq && mkdir -p /usr/local/pgsql/lib
312+ RUN --mount=type=bind,from=builder,source=/var/libpq,target=/var/libpq,rw \
313+ cp -a /var/libpq/libpq.* /usr/local/pgsql/lib && \
314+ echo "/usr/local/pgsql/lib" > /etc/ld.so.conf.d/libpq.conf && \
315+ ldconfig
316+
301317COPY --from=builder /tmp/lightning_install/ /usr/local/
302318COPY --from=builder-python /usr/local/lib/python3.9/dist-packages/ /usr/local/lib/python3.9/dist-packages/
303319COPY --from=downloader /opt/bitcoin/bin /usr/bin
0 commit comments