zonkyio / embedded-postgres

Java embedded PostgreSQL component for testing
Apache License 2.0
344 stars 43 forks source link

libpam.so.0 issue in docker #82

Closed badbyte closed 2 years ago

badbyte commented 2 years ago

Embedded postgres can't run in some (all quarkus build images. ex: quay.io/quarkus/ubi-quarkus-native-image:21.3.0-java17) docker images (non-root user)

Process [/tmp/embedded-pg/PG-f2e3e42c260d3a84f6730bd8bccfb393/bin/initdb, -A, trust, -U, postgres, -D, /tmp/epg17377939173514313626, -E, UTF-8] failed

manual run in container gives: sh-4.4$ /tmp/embedded-pg/PG-f2e3e42c260d3a84f6730bd8bccfb393/bin/initdb -A trust -U postgres -D /tmp/epg17377939173514313626 -E UTF-8

/tmp/embedded-pg/PG-f2e3e42c260d3a84f6730bd8bccfb393/bin/postgres: error while loading shared libraries: libpam.so.0: cannot open shared object file: No such file or directory no data was returned by command ""/tmp/embedded-pg/PG-f2e3e42c260d3a84f6730bd8bccfb393/bin/postgres" -V" The program "postgres" is needed by initdb but was not found in the same directory as "/tmp/embedded-pg/PG-f2e3e42c260d3a84f6730bd8bccfb393/bin/initdb". Check your installation.

sh-4.4$ cat /etc/os-release NAME="Red Hat Enterprise Linux" VERSION="8.5 (Ootpa)" ID="rhel" ID_LIKE="fedora" VERSION_ID="8.5" PLATFORM_ID="platform:el8" PRETTY_NAME="Red Hat Enterprise Linux 8.5 (Ootpa)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:redhat:enterprise_linux:8::baseos" HOME_URL="https://www.redhat.com/" DOCUMENTATION_URL="https://access.redhat.com/documentation/red_hat_enterprise_linux/8/" BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8" REDHAT_BUGZILLA_PRODUCT_VERSION=8.5 REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux" REDHAT_SUPPORT_PRODUCT_VERSION="8.5"

tomix26 commented 2 years ago

I guess this problem is not caused by an error in postgres binaries, but by a missing package on the target system. Try to execute yum install pam-devel command inside the docker container and let me know it it helped.

badbyte commented 2 years ago

There is no way to install anything in quarkus-native containers afaik. That's why the issue was created. Is it possible to add libpam to the embedded-postgres bundle ?

tomix26 commented 2 years ago

I think that it isn't. Because the libpam library is system specific and is not present even in regular postgres binaries. So it doesn't make sense to add it to this lightweight bundle.

But it should be quite easy to solve the problem by installing the missing library before running the build. So, for example, instead of calling ./gradlew build you can call yum install pam-devel && ./gradlew build. And this should ensure that the missing library is installed before the gradle build being executed.