首页 > 解决方案 > Is there a way to compile cURL and all deps to a specific directory?

问题描述

I'm trying to compile cURL for busybox on multiple platforms, but I need to copy it to another Docker container once it's built. I previously had this working with this:

RUN wget -q https://curl.haxx.se/download/curl-7.63.0.tar.gz && \
    tar xzf curl-7.63.0.tar.gz && \
    cd curl-7.63.0 && \
    LIBS="-ldl" ./configure --disable-shared && \
    make && \
    make install

However, for some reason, perhaps a mistake I've made, it is no longer compiling statically and requires libs like libcurl, libz etc. Previously I had it working only requiring libssl/libcrypto etc.

So my question is really, is there a way to compile cURL and all of it's deps and shared libraries, to a specific directory so that I can copy that rather than trying to build a statically linked binary to copy?

Thanks

标签: curlcompilation

解决方案


对于它的价值,这是可能的--prefix=/build论点。

用于构建(非常精简)cURL 的完整 Dockerfile 是:

FROM buildpack-deps:stretch-scm
ARG VERSION=7.63.0

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
      g++ gcc libc6-dev make pkg-config
RUN apt-get install -y libssl-dev

RUN wget -q https://curl.haxx.se/download/curl-${VERSION}.tar.gz && \
    tar xzf curl-${VERSION}.tar.gz

WORKDIR curl-${VERSION}

RUN ./configure --prefix=/build \
      --without-zlib \
      --disable-cookies \
      --disable-verbose \
      --disable-versioned-symbols \
      --disable-shared --enable-static \
      --disable-ftps --disable-gopher \
      --disable-imap --disable-imaps \
      --disable-ldap --disable-ldaps \
      --disable-pop3 --disable-pop3s \
      --disable-rtmp --disable-rtsp \
      --disable-dict --disable-file \
      --disable-ftp --disable-sftp \
      --disable-smb --disable-smbs \
      --disable-smtp --disable-smtps \
      --disable-telnet --disable-tftp && \
    make && \
    make install

然后,您可以像这样提取它:

ARG CURL_IMAGE

FROM ${CURL_IMAGE} AS base
FROM busybox

ARG LIB_LOCATION

COPY --from=base /build/bin/curl /usr/sbin/curl
COPY --from=base ${LIB_LOCATION}/libssl.so.1.1 ${LIB_LOCATION}/libssl.so.1.1
COPY --from=base ${LIB_LOCATION}/libcrypto.so.1.1 ${LIB_LOCATION}/libcrypto.so.1.1

这很可能在将来只对我有用,但是你去吧。

编辑:LIB_LOCATION 是 amd64、arm64 和 arm 的以下之一。

/usr/lib/x86_64-linux-gnu
/usr/lib/arm-linux-gnueabihf
/usr/lib/aarch64-linux-gnu


推荐阅读