Reputation: 125
I need a git binary with https support in a distroless Docker image. I'm using musl C library and compiler - installed from Ubuntu repo - to statically compile git and all of its dependencies (libcurl, openssl). The compilation succeeds, but when I try to clone a repo, I get an error:
./fg_gitlab_runner/fargate-driver-debian/output/bin/git clone https://github.com/GoogleContainerTools/kaniko.git
Cloning into 'kaniko'...
fatal: unable to access 'https://github.com/GoogleContainerTools/kaniko.git/': Protocol "https" not supported
OpenSSL is compilled as follows:
CFLAGS="-Wl,-static" LDFLAGS="-static" ./Configure --prefix=/home/karaluh/fg_gitlab_runner/fargate-driver-debian/openssl-output --openssldir=/home/karaluh/fg_gitlab_runner/fargate-driver-debian/openssl-output/ssl CC="musl-gcc -idirafter /usr/include/"
make
make install
curl:
./configure prefix=~/fg_gitlab_runner/fargate-driver-debian/curl-output LDFLAGS="-static -L/home/karaluh/fg_gitlab_runner/fargate-driver-debian/openssl-output/lib64/" CC="musl-gcc" CFLAGS="-Wl,-static" CPPFLAGS="-I /home/karaluh/fg_gitlab_runner/fargate-driver-debian/openssl-output/include" --with-openssl
make
make install
and git:
make configure
./configure prefix=~/fg_gitlab_runner/fargate-driver-debian/output LDFLAGS="-static -L/home/karaluh/fg_gitlab_runner/fargate-driver-debian/zlib-tar/zlib-1.3.1 -L/home/karaluh/fg_gitlab_runner/fargate-driver-debian/curl-output/lib" CC="musl-gcc" CFLAGS="-Wl,-static" CPPFLAGS="-I /home/karaluh/fg_gitlab_runner/fargate-driver-debian/zlib-tar/zlib-1.3.1 -I /home/karaluh/fg_gitlab_runner/fargate-driver-debian/curl-output/include"
PATH=$PATH:~/fg_gitlab_runner/fargate-driver-debian/curl-output/bin make NO_OPENSSL=1 NO_EXPAT=1 NO_GETTEXT=1 NO_PERL=1 NO_PYTHON=1 NO_TCLTK=1 install
I can use the compiled curl binary to access an https website, so I'm assuming libcurl is compiled correctly. I can also see that git-remote-https is present in output/libexec/git-core.
The cause seems to be a lot of undefined references shown in git's config.log but I have no idea what to do with these:
/usr/bin/ld: /home/karaluh/fg_gitlab_runner/fargate-driver-debian/curl-output/lib/libcurl.a(libcurl_la-openssl.o): in function `ssl_ui_reader': openssl.c:(.text+0x243): undefined reference to `UI_get_string_type'
Upvotes: 2
Views: 138