Skip to content

postgres alpine images too large (llvm) #1044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
harmv opened this issue Feb 8, 2023 · 2 comments
Closed

postgres alpine images too large (llvm) #1044

harmv opened this issue Feb 8, 2023 · 2 comments

Comments

@harmv
Copy link

harmv commented Feb 8, 2023

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
@harmv harmv changed the title postgres alpine images large (llvm) postgres alpine images too large (llvm) Feb 8, 2023
@tianon
Copy link
Member

tianon commented Feb 8, 2023

We discussed the size trade-off in #475, but the conclusion is that PostgreSQL actively recommends having this functionality enabled and actively using it for large queries. Our goal is to follow upstream as closely as possible, so we opted to follow suit even on Alpine where it's (unfortunately) a significant size increase. 😞

@harmv
Copy link
Author

harmv commented Feb 9, 2023

Hm. I understand.

Not sure I agree with the trade-off that was made. 130MB is pretty significant. For a feature that has limited benefits (JIT).
But anyway, thats how it is....
I guess this ticket can be closed then.

Is there such a thing as an alpine-slim flavour?
I'm in favour for that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants