I need to create a custom Postgres Docker container with many plugins. So far, I've gotten only one of them working. Another, pg_repack, is giving me grief.
So far, here is what I've got for my Dockerfile:
FROM postgres:16
RUN apt-get update && apt-get install -y \
postgresql-server-dev-16 \
build-essential \
libpq-dev \
wget \
make \
gcc \
postgresql-plpython3-16
RUN wget https://github.com/reorg/pg_repack/archive/refs/tags/ver_1.5.0.tar.gz \
&& tar zxvf ver_1.5.0.tar.gz \
&& cd pg_repack-ver_1.5.0 \
&& make \
&& make install
RUN apt-get remove -y wget build-essential postgresql-server-dev-16 gcc \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
It seems to install plpython3u okay, but chokes at pg_repack:
[...]
0.463 make[1]: Entering directory '/pg_repack-ver_1.5.0/bin'
0.477 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -I/usr/include/postgresql -DREPACK_VERSION=1.5.0 -I. -I./ -I/usr/include/postgresql/16/server -I/usr/include/postgresql/internal -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -c -o pg_repack.o pg_repack.c
0.752 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -I/usr/include/postgresql -DREPACK_VERSION=1.5.0 -I. -I./ -I/usr/include/postgresql/16/server -I/usr/include/postgresql/internal -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -c -o pgut/pgut.o pgut/pgut.c
0.956 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -I/usr/include/postgresql -DREPACK_VERSION=1.5.0 -I. -I./ -I/usr/include/postgresql/16/server -I/usr/include/postgresql/internal -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -c -o pgut/pgut-fe.o pgut/pgut-fe.c
1.084 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer pg_repack.o pgut/pgut.o pgut/pgut-fe.o -L/usr/lib/x86_64-linux-gnu -Wl,-z,relro -Wl,-z,now -L/usr/lib/llvm-15/lib -Wl,--as-needed -L/usr/lib/x86_64-linux-gnu -lpq -L/usr/lib/postgresql/16/lib -lpgcommon -lpgport -lzstd -llz4 -lssl -lcrypto -lz -lreadline -lm -o pg_repack
1.087 /usr/bin/ld: cannot find -lzstd: No such file or directory
1.087 /usr/bin/ld: cannot find -llz4: No such file or directory
1.091 /usr/bin/ld: cannot find -lz: No such file or directory
1.092 /usr/bin/ld: cannot find -lreadline: No such file or directory
1.093 collect2: error: ld returned 1 exit status
1.093 make[1]: *** [/usr/lib/postgresql/16/lib/pgxs/src/makefiles/pgxs.mk:478: pg_repack] Error 1
1.093 make[1]: Leaving directory '/pg_repack-ver_1.5.0/bin'
1.094 make: *** [Makefile:35: all] Error 2
------
failed to solve: process "/bin/sh -c wget https://github.com/reorg/pg_repack/archive/refs/tags/ver_1.5.0.tar.gz && tar zxvf ver_1.5.0.tar.gz && cd pg_repack-ver_1.5.0 && make && make install" did not complete successfully: exit code: 2
You have to install the missing dependencies:
FROM postgres:16
RUN apt-get update && apt-get install -y \
build-essential \
gcc \
liblz4-dev \
libpq-dev \
libreadline-dev \
libzstd-dev \
make \
postgresql-plpython3-16 \
postgresql-server-dev-16 \
wget \
zlib1g-dev
RUN wget https://github.com/reorg/pg_repack/archive/refs/tags/ver_1.5.0.tar.gz \
&& tar zxvf ver_1.5.0.tar.gz \
&& cd pg_repack-ver_1.5.0 \
&& make \
&& make install
RUN apt-get remove -y wget build-essential postgresql-server-dev-16 gcc \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*