Skip to content

Commit

Permalink
Remove curl binary from fargate build (#2380)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramanan-ravi authored Dec 2, 2024
1 parent 4ee9f8f commit 645ef8d
Showing 1 changed file with 0 additions and 111 deletions.
111 changes: 0 additions & 111 deletions deepfence_agent/agent-binary/Dockerfile.fargate
Original file line number Diff line number Diff line change
@@ -1,113 +1,3 @@
FROM alpine:3.19 as builder

# renovate: source=github-tags name=curl/curl versioning=regex:^(?:curl-)?(?<major>\d+)_(?<minor>\d+)_(?<patch>\d+)$ extractVersion=^(?:curl-)?(?<version>[\d_]+)$
ENV CURL_VERSION="8_5_0"

# install system dependencies
RUN apk add \
build-base \
clang \
openssl-dev \
nghttp2-dev \
nghttp2-static \
openssl-libs-static \
zlib-static \
autoconf \
automake \
libtool

WORKDIR /tmp

# download curl sources
RUN set -x \
&& CURL_VERSION=$(echo $CURL_VERSION | sed s/_/./g) \
&& wget -O curl.tar.gz "https://curl.haxx.se/download/curl-$CURL_VERSION.tar.gz" \
&& tar xzf curl.tar.gz \
&& rm curl.tar.gz \
&& mv ./curl-* ./src

# change working directory to the directory with curl sources
WORKDIR /tmp/src

# apply patches to the source code
# COPY ./patches ./patches
RUN mkdir -p ./patches \
&& wget https://raw.githubusercontent.com/tarampampam/curl-docker/master/patches/fail-exit-code.patch -O ./patches/fail-exit-code.patch
RUN for f in ./patches/*.patch; do patch -p1 < "$f"; done

ENV CC="clang" \
LDFLAGS="-static" \
PKG_CONFIG="pkg-config --static"

RUN autoreconf -fi

#RUN ./configure --help=short && exit 1 # show the help

RUN ./configure \
--disable-shared \
--enable-static \
\
--enable-dnsshuffle \
--enable-werror \
\
--disable-cookies \
--disable-crypto-auth \
--disable-dict \
--disable-file \
--disable-ftp \
--disable-gopher \
--disable-imap \
--disable-ldap \
--disable-pop3 \
--disable-proxy \
--disable-rtmp \
--disable-rtsp \
--disable-scp \
--disable-sftp \
--disable-smtp \
--disable-telnet \
--disable-tftp \
--disable-versioned-symbols \
--disable-doh \
--disable-netrc \
--disable-mqtt \
--disable-largefile \
--without-gssapi \
--without-libidn2 \
--without-libpsl \
--without-librtmp \
--without-libssh2 \
--without-nghttp2 \
--without-ntlm-auth \
--without-brotli \
--without-zlib \
--with-ssl

# compile the curl
RUN set -x \
&& make -j$(nproc) V=1 LDFLAGS="-static -all-static" \
&& strip ./src/curl

# exit with error code 1 if the executable is dynamic, not static
RUN ldd ./src/curl && exit 1 || true

# print out some info about binary file
RUN set -x \
&& ls -lh ./src/curl \
&& file ./src/curl \
&& ./src/curl --version

WORKDIR /tmp/rootfs

# prepare the rootfs for scratch
RUN set -x \
&& mkdir -p ./bin ./etc/ssl \
&& mv /tmp/src/src/curl ./bin/curl \
&& echo 'curl:x:10001:10001::/nonexistent:/sbin/nologin' > ./etc/passwd \
&& echo 'curl:x:10001:' > ./etc/group \
&& cp -R /etc/ssl/certs ./etc/ssl/certs


FROM scratch

ARG AGENT_BINARY_BUILD_RELATIVE
Expand All @@ -120,7 +10,6 @@ WORKDIR /
COPY $AGENT_BINARY_BUILD_RELATIVE /deepfence

COPY deepfence_agent/agent-binary/deepfence-entry-point-scratch.sh deepfence/usr/local/bin/deepfence-entry-point-scratch.sh
COPY --from=builder /tmp/rootfs/bin/curl /deepfence/bin/curl
COPY deepfence_agent/agent-binary/start-df-services-fargate.sh deepfence/usr/local/bin/start-df-services-fargate.sh

VOLUME ["/deepfence"]
Expand Down

0 comments on commit 645ef8d

Please sign in to comment.