Description
I noticed that the postgres alpine images are quite large.
postgres 13.9-alpine 8e750948d39a 4 weeks ago 238MB
A big part is caused by liblvm15
/ # ls -lh /usr/lib/libLLVM-15.*
lrwxrwxrwx 1 root root 13 Jan 9 19:27 /usr/lib/libLLVM-15.0.6.so -> libLLVM-15.so
-rwxr-xr-x 1 root root 125.3M Nov 29 20:09 /usr/lib/libLLVM-15.so
This is part of .postgresql-rundeps, as postgres is compiled with the --with-llvm option, even for the alpine build flavor. (In order to support JIT)
Given that alpine docker builds are supposed to use little disk space you might wonder if that is desired.
Suggestion: Build postgres alpine build without the --with-llvm option, to get lean 'alpine' postgres images.
Or alternatively some trickery in the runDeps might be appropriate. I noticed that the postgres Dockerfile already filters out manually the python/perl/tcl dependencies. That could be extended for liblvm.
Something like this:
(Dockerfile)
--- a/Dockerfile
+++ b/Dockerfile
@@ -120,6 +120,9 @@ RUN set -eux; \
# Remove plperl, plpython and pltcl dependencies by default to save image size
# To use the pl extensions, those have to be installed in a derived image
| grep -v -e perl -e python -e tcl \
+# Remove libLVM (required for JIT) dependency by default to save image size
+# To use the jit features, this library has to be installed in a derived image
+ | grep -v -e LLVM \
)"; \
apk add --no-cache --virtual .postgresql-rundeps \
$runDeps \
result
before:
postgres 13-alpine3.17 243 MB
After:
postgres 13-alpine3.17 111 MB