FROM public.ecr.aws/docker/library/alpine:3.20.3 as builder ARG OPENSSL_CONFIG RUN apk add --no-cache build-base cmake git autoconf automake libtool perl linux-headers make gcc musl-dev g++ boost-dev boost-static ADD . /app RUN mkdir /app/dependencies RUN cd /app/dependencies && \ wget https://github.com/madler/zlib/archive/v1.2.13.tar.gz -O /tmp/zlib-1.2.13.tar.gz && \ tar xzvf /tmp/zlib-1.2.13.tar.gz && \ cd zlib-1.2.13 && \ CFLAGS="-fPIC" ./configure -static && \ make -j$(nproc) && \ make install RUN cd /app/dependencies && \ wget https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.gz && \ tar xzvf boost_1_81_0.tar.gz && \ cd boost_1_81_0 && \ ./bootstrap.sh && \ ./b2 install link=static cxxflags="-std=c++17 -fPIC" runtime-link=static -j$(nproc) RUN cd /app/dependencies && \ wget https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-cpp-3.17.3.tar.gz -O /tmp/protobuf-cpp-3.17.3.tar.gz && \ tar xzvf /tmp/protobuf-cpp-3.17.3.tar.gz && \ cd protobuf-3.17.3 && \ ./autogen.sh && \ CXXFLAGS="-fPIC -std=c++17" ./configure --disable-shared --enable-static --prefix=/usr && \ make -j$(nproc) && \ make install RUN cd /app/dependencies && \ wget https://www.openssl.org/source/openssl-1.1.1l.tar.gz && \ tar -xzf openssl-1.1.1l.tar.gz && \ cd openssl-1.1.1l && \ ./config no-shared -fPIC --prefix=/usr --openssldir=/usr/lib && \ make -j$(nproc) && \ make install RUN cd /app && \ mkdir -p build && \ cd build && \ cmake .. && \ make -j$(nproc) && \ strip bin/localproxy FROM scratch COPY --from=builder /app/build/bin/localproxy /bin/localproxy