build: Fixes for the Docker building libpq lib.
- Add Postgres dependencies: bison, flex and libiu-dev. - Fix missing `&&` in chained wget commands. - Add `POSTGRES_CONFIG` and `PG_CONFIG` for all architectures. - Remove existing `libpq` Ubuntu packages. - Copy libpq libraries from builder directly to final image. Changelog-Fixed: Fixes Postgres driver availability for arm64 and arm32 Docker images.
This commit is contained in:
46
Dockerfile
46
Dockerfile
@@ -60,15 +60,17 @@ RUN apt-get update -qq && \
|
||||
apt-get install -qq -y --no-install-recommends \
|
||||
autoconf \
|
||||
automake \
|
||||
bison \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
curl \
|
||||
dirmngr \
|
||||
flex \
|
||||
gettext \
|
||||
git \
|
||||
gnupg \
|
||||
jq \
|
||||
libpq-dev \
|
||||
libicu-dev \
|
||||
libtool \
|
||||
libffi-dev \
|
||||
pkg-config \
|
||||
@@ -88,14 +90,15 @@ RUN apt-get update -qq && \
|
||||
tclsh
|
||||
|
||||
ENV PATH="/root/.local/bin:$PATH"
|
||||
ENV PYTHON_VERSION=3
|
||||
ENV PYTHON_VERSION=3 \
|
||||
PIP_BREAK_SYSTEM_PACKAGES=1
|
||||
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
|
||||
RUN poetry self add poetry-plugin-export
|
||||
|
||||
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 \
|
||||
wget -q https://www.sqlite.org/2019/sqlite-src-3290000.zip -O sqlite.zip && \
|
||||
wget -q https://ftp.postgresql.org/pub/source/v17.1/postgresql-17.1.tar.gz -O postgres.tar.gz
|
||||
|
||||
WORKDIR /opt/lightningd
|
||||
@@ -110,6 +113,9 @@ WORKDIR /
|
||||
|
||||
FROM base-builder AS base-builder-linux-amd64
|
||||
|
||||
ENV POSTGRES_CONFIG="--without-readline" \
|
||||
PG_CONFIG=/usr/local/pgsql/bin/pg_config
|
||||
|
||||
FROM base-builder AS base-builder-linux-arm64
|
||||
ENV target_host=aarch64-linux-gnu \
|
||||
target_host_rust=aarch64-unknown-linux-gnu \
|
||||
@@ -130,12 +136,13 @@ QEMU_LD_PREFIX=/usr/${target_host} \
|
||||
HOST=${target_host} \
|
||||
TARGET=${target_host_rust} \
|
||||
RUSTUP_INSTALL_OPTS="--target ${target_host_rust} --default-host ${target_host_rust}" \
|
||||
PKG_CONFIG_PATH="/usr/${target_host}/lib/pkgconfig" \
|
||||
PG_CONFIG_PATH="/usr/${target_host}/bin/pg_config"
|
||||
PKG_CONFIG_PATH="/usr/${target_host}/lib/pkgconfig"
|
||||
|
||||
ENV \
|
||||
ZLIB_CONFIG="--prefix=${QEMU_LD_PREFIX}" \
|
||||
SQLITE_CONFIG="--host=${target_host} --prefix=$QEMU_LD_PREFIX"
|
||||
SQLITE_CONFIG="--host=${target_host} --prefix=${QEMU_LD_PREFIX}" \
|
||||
POSTGRES_CONFIG="--without-readline --prefix=${QEMU_LD_PREFIX}" \
|
||||
PG_CONFIG="${QEMU_LD_PREFIX}/bin/pg_config"
|
||||
|
||||
FROM base-builder AS base-builder-linux-arm
|
||||
|
||||
@@ -158,13 +165,13 @@ QEMU_LD_PREFIX=/usr/${target_host} \
|
||||
HOST=${target_host} \
|
||||
TARGET=${target_host_rust} \
|
||||
RUSTUP_INSTALL_OPTS="--target ${target_host_rust} --default-host ${target_host_rust}" \
|
||||
PKG_CONFIG_PATH="/usr/${target_host}/lib/pkgconfig" \
|
||||
PG_CONFIG_PATH="/usr/${target_host}/bin/pg_config"
|
||||
PKG_CONFIG_PATH="/usr/${target_host}/lib/pkgconfig"
|
||||
|
||||
ENV \
|
||||
ZLIB_CONFIG="--prefix=${QEMU_LD_PREFIX}" \
|
||||
SQLITE_CONFIG="--host=${target_host} --prefix=$QEMU_LD_PREFIX" \
|
||||
POSTGRES_CONFIG="--without-readline --prefix=${QEMU_LD_PREFIX}"
|
||||
SQLITE_CONFIG="--host=${target_host} --prefix=${QEMU_LD_PREFIX}" \
|
||||
POSTGRES_CONFIG="--without-readline --prefix=${QEMU_LD_PREFIX}" \
|
||||
PG_CONFIG="${QEMU_LD_PREFIX}/bin/pg_config"
|
||||
|
||||
FROM base-builder-${TARGETOS}-${TARGETARCH} AS builder
|
||||
|
||||
@@ -198,6 +205,9 @@ RUN mkdir postgres && tar xvf postgres.tar.gz -C postgres --strip-components=1 \
|
||||
rm -rf postgres && \
|
||||
ldconfig "$(${PG_CONFIG} --libdir)"
|
||||
|
||||
# Save libpq to a specific location to copy it into the final image.
|
||||
RUN mkdir /var/libpq && cp -a "$(${PG_CONFIG} --libdir)"/libpq.* /var/libpq
|
||||
|
||||
ENV RUST_PROFILE=release
|
||||
ENV PATH="/root/.cargo/bin:/root/.local/bin:$PATH"
|
||||
RUN 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 && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
|
||||
ENV PYTHON_VERSION=3
|
||||
ENV PYTHON_VERSION=3 \
|
||||
PIP_BREAK_SYSTEM_PACKAGES=1
|
||||
RUN pip3 install --upgrade pip setuptools wheel
|
||||
|
||||
# Copy rustup_install_opts.txt file from builder
|
||||
@@ -283,9 +293,8 @@ RUN apt-get update && \
|
||||
socat \
|
||||
inotify-tools \
|
||||
jq \
|
||||
python3.9 \
|
||||
python3-pip \
|
||||
libpq5 && \
|
||||
python3 \
|
||||
python3-pip && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
@@ -298,6 +307,13 @@ RUN mkdir $LIGHTNINGD_DATA && \
|
||||
touch $LIGHTNINGD_DATA/config
|
||||
VOLUME [ "/root/.lightning" ]
|
||||
|
||||
# Take libpq directly from builder.
|
||||
RUN mkdir /var/libpq && mkdir -p /usr/local/pgsql/lib
|
||||
RUN --mount=type=bind,from=builder,source=/var/libpq,target=/var/libpq,rw \
|
||||
cp -a /var/libpq/libpq.* /usr/local/pgsql/lib && \
|
||||
echo "/usr/local/pgsql/lib" > /etc/ld.so.conf.d/libpq.conf && \
|
||||
ldconfig
|
||||
|
||||
COPY --from=builder /tmp/lightning_install/ /usr/local/
|
||||
COPY --from=builder-python /usr/local/lib/python3.9/dist-packages/ /usr/local/lib/python3.9/dist-packages/
|
||||
COPY --from=downloader /opt/bitcoin/bin /usr/bin
|
||||
|
||||
Reference in New Issue
Block a user