From 39c3143fe76d4a58033beb656dcf262bcdc3d394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Trigo=20Soares?= Date: Mon, 13 May 2024 19:00:38 +0100 Subject: [PATCH] added HTTP/3 support to cURL --- Dockerfile | 117 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 85 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index 83ffff5..6f7b1b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,49 @@ +FROM debian:12 AS builder + +# this builder part is the work of Yury Muski, from https://github.com/yurymuski/curl-http3 +LABEL maintainer="Yury Muski " + +WORKDIR /opt + +ARG CURL_VERSION=curl-8_2_1 +ARG QUICHE_VERSION=0.18.0 + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git autoconf libtool cmake golang-go curl libnghttp2-dev zlib1g-dev; + +# https://github.com/curl/curl/blob/master/docs/HTTP3.md#quiche-version + +# install rust & cargo +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y -q; + +RUN git clone --recursive https://github.com/cloudflare/quiche + +# build quiche +RUN export PATH="$HOME/.cargo/bin:$PATH" && \ + cd quiche && \ + git checkout $QUICHE_VERSION && \ + cargo build --package quiche --release --features ffi,pkg-config-meta,qlog && \ + mkdir quiche/deps/boringssl/src/lib && \ + ln -vnf $(find target/release -name libcrypto.a -o -name libssl.a) quiche/deps/boringssl/src/lib/ + + +# add curl +RUN git clone https://github.com/curl/curl +RUN cd curl && \ + git checkout $CURL_VERSION && \ + autoreconf -fi && \ + ./configure LDFLAGS="-Wl,-rpath,/opt/quiche/target/release" --with-openssl=/opt/quiche/quiche/deps/boringssl/src --with-quiche=/opt/quiche/target/release --with-nghttp2 --with-zlib && \ + make && \ + make DESTDIR="/debian/" install + + # match doks-debug version with DOKS worker node image version for kernel # tooling compatibility reasons FROM debian:stable-slim LABEL org.opencontainers.image.source=https://github.com/nosportugal/debug-pod LABEL org.opencontainers.image.description="A debian image with some debugging tools installed." +LABEL org.opencontainers.image.authors="NOS Portugal" WORKDIR /root @@ -17,38 +57,48 @@ RUN echo 'path-include=/usr/share/doc/*/changelog.Debian.*' > /etc/dpkg/dpkg.cfg RUN echo 'deb http://deb.debian.org/debian bullseye-backports main' > /etc/apt/sources.list.d/backports.list RUN apt-get update && \ - apt-get install -y apt-transport-https \ - ca-certificates \ - software-properties-common \ - httping \ - man \ - man-db \ - vim \ - screen \ - curl \ - gnupg \ - atop \ - htop \ - dstat \ - jq \ - dnsutils \ - tcpdump \ - traceroute \ - iputils-ping \ - net-tools \ - ncat \ - iproute2 \ - strace \ - telnet \ - openssl \ - psmisc \ - dsniff \ - mtr-tiny \ - conntrack \ - bpftool \ - nmap \ - redis-tools \ - kafkacat + apt-get install -y \ + apt-transport-https \ + ca-certificates \ + software-properties-common \ + httping \ + man \ + man-db \ + vim \ + screen \ + gnupg \ + atop \ + htop \ + dstat \ + jq \ + dnsutils \ + tcpdump \ + traceroute \ + iputils-ping \ + net-tools \ + ncat \ + iproute2 \ + strace \ + telnet \ + openssl \ + psmisc \ + dsniff \ + mtr-tiny \ + conntrack \ + bpftool \ + nmap \ + redis-tools \ + kafkacat \ + nghttp2 \ + zlib1g && \ + rm -rf /var/lib/apt/lists/* + +COPY --from=builder /debian/usr/local/ /usr/local/ +COPY --from=builder /opt/quiche/target/release /opt/quiche/target/release + +# Resolve any issues of C-level lib +# location caches ("shared library cache") +RUN ldconfig RUN install -m 0755 -d /etc/apt/keyrings && \ . /etc/os-release && \ @@ -74,4 +124,7 @@ RUN curl -Lv -o /usr/bin/hey https://hey-release.s3.us-east-2.amazonaws.com/hey_ RUN curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | bash && \ apt-get install -y speedtest +# add httpstat script +RUN curl -s https://raw.githubusercontent.com/b4b4r07/httpstat/master/httpstat.sh >httpstat.sh && chmod +x httpstat.sh + ENTRYPOINT [ "/bin/bash" ]