|
| 1 | +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env |
| 2 | + |
| 3 | +COPY . . |
| 4 | + |
| 5 | +ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 |
| 6 | +ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 |
| 7 | + |
| 8 | +# Build self contained |
| 9 | +RUN dotnet publish -c Release src/Microsoft.Crank.Agent --output /app --framework net8.0 |
| 10 | + |
| 11 | +# Build runtime image |
| 12 | +# FROM mcr.microsoft.com/dotnet/aspnet:8.0 |
| 13 | +# Use SDK image as it is required for the dotnet tools |
| 14 | +FROM mcr.microsoft.com/dotnet/sdk:8.0 |
| 15 | + |
| 16 | +ARG CPUNAME=x86_64 |
| 17 | +ARG ENABLE_FIPS_MODE=false |
| 18 | +ARG OPENSSL_CIPHER_STRING=TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256 |
| 19 | +ARG OPENSSL_GROUPS=P-384:P-256:P-521 |
| 20 | + |
| 21 | +# Install dotnet-symbols |
| 22 | +RUN dotnet tool install -g dotnet-symbol |
| 23 | +ENV PATH="${PATH}:/root/.dotnet/tools" |
| 24 | + |
| 25 | +# Install dependencies |
| 26 | +RUN apt-get update \ |
| 27 | + && apt-get install -y --no-install-recommends \ |
| 28 | + git \ |
| 29 | + procps \ |
| 30 | + cgroup-tools \ |
| 31 | + curl \ |
| 32 | + wget \ |
| 33 | + nano \ |
| 34 | + # dotnet performance repo microbenchmark dependencies |
| 35 | + libgdiplus \ |
| 36 | + # libmsquic requirements |
| 37 | + gnupg2 \ |
| 38 | + software-properties-common \ |
| 39 | + # NativeAOT requirements |
| 40 | + clang \ |
| 41 | + zlib1g-dev \ |
| 42 | + libkrb5-dev \ |
| 43 | + # .NET 9.0 requirement |
| 44 | + libc6 |
| 45 | + |
| 46 | +# Install HTTP/3 support |
| 47 | +RUN curl -LO https://packages.microsoft.com/keys/microsoft.asc && \ |
| 48 | + echo 2fa9c05d591a1582a9aba276272478c262e95ad00acf60eaee1644d93941e3c6 microsoft.asc| sha256sum --check - && \ |
| 49 | + apt-key add microsoft.asc && \ |
| 50 | + rm microsoft.asc && \ |
| 51 | + echo deb https://packages.microsoft.com/debian/12/prod bookworm main >> /etc/apt/sources.list.d/microsoft.list && \ |
| 52 | + apt-get update && \ |
| 53 | + apt-get install -y libmsquic && \ |
| 54 | + rm -rf /var/lib/apt/lists/* |
| 55 | + |
| 56 | +# Build and install h2load. Required as there isn't a way to distribute h2load as a single file to download |
| 57 | +RUN apt-get update \ |
| 58 | + && apt-get install -y --no-install-recommends \ |
| 59 | + g++ make binutils autoconf automake autotools-dev libtool pkg-config \ |
| 60 | + zlib1g-dev libcunit1-dev libxml2-dev libev-dev libevent-dev libjansson-dev \ |
| 61 | + libc-ares-dev libjemalloc-dev libsystemd-dev \ |
| 62 | + python-is-python3 python3-dev python3-setuptools |
| 63 | + |
| 64 | +ENV DEBIAN_FRONTEND=noninteractive |
| 65 | +# Add the Debian sid repository |
| 66 | +RUN echo 'deb http://deb.debian.org/debian sid main' >> /etc/apt/sources.list \ |
| 67 | + && echo 'deb http://deb.debian.org/debian-debug sid-debug main' >> /etc/apt/sources.list |
| 68 | + |
| 69 | +RUN apt-get update \ |
| 70 | + && apt-get install -y --no-install-recommends \ |
| 71 | + openssl libssl-dev openssl-dbgsym libssl3t64-dbgsym \ |
| 72 | + && openssl version |
| 73 | + |
| 74 | +# Configure OpenSSL for FIPS-compliant cipher suites if $ENABLE_FIPS_MODE |
| 75 | +RUN if [ "$ENABLE_FIPS_MODE" = "true" ]; then \ |
| 76 | + echo "=== FIPS MODE ENABLED - Configuring OpenSSL ===" && \ |
| 77 | + cat /etc/ssl/openssl.cnf && \ |
| 78 | + echo "" >> /etc/ssl/openssl.cnf && \ |
| 79 | + echo "openssl_conf = openssl_init" >> /etc/ssl/openssl.cnf && \ |
| 80 | + echo "[openssl_init]" >> /etc/ssl/openssl.cnf && \ |
| 81 | + echo "ssl_conf = ssl_sect" >> /etc/ssl/openssl.cnf && \ |
| 82 | + echo "[ssl_sect]" >> /etc/ssl/openssl.cnf && \ |
| 83 | + echo "system_default = system_default_sect" >> /etc/ssl/openssl.cnf && \ |
| 84 | + echo "[system_default_sect]" >> /etc/ssl/openssl.cnf && \ |
| 85 | + echo "CipherString = $OPENSSL_CIPHER_STRING" >> /etc/ssl/openssl.cnf && \ |
| 86 | + echo "Groups = $OPENSSL_GROUPS" >> /etc/ssl/openssl.cnf && \ |
| 87 | + echo "=== FIPS Configuration Applied ===" && \ |
| 88 | + tail -15 /etc/ssl/openssl.cnf; \ |
| 89 | + else \ |
| 90 | + echo "=== FIPS MODE DISABLED ==="; \ |
| 91 | + fi |
| 92 | + |
| 93 | +# If nghttp2 build fail just ignore it |
| 94 | +ENV NGHTTP2_VERSION=1.58.0 |
| 95 | +RUN cd /tmp \ |
| 96 | + && curl -L "https://github.com/nghttp2/nghttp2/releases/download/v${NGHTTP2_VERSION}/nghttp2-${NGHTTP2_VERSION}.tar.gz" -o "nghttp2-${NGHTTP2_VERSION}.tar.gz" \ |
| 97 | + && tar -zxvf "nghttp2-${NGHTTP2_VERSION}.tar.gz" \ |
| 98 | + && cd /tmp/nghttp2-$NGHTTP2_VERSION \ |
| 99 | + && ./configure \ |
| 100 | + && make \ |
| 101 | + && make install || true |
| 102 | + |
| 103 | +# Install docker client |
| 104 | +ENV DOCKER_VERSION=17.09.0-ce |
| 105 | +RUN cd /tmp \ |
| 106 | + && curl "https://download.docker.com/linux/static/stable/${CPUNAME}/docker-${DOCKER_VERSION}.tgz" -o docker.tgz \ |
| 107 | + && tar xvzf docker.tgz \ |
| 108 | + && cp docker/docker /usr/bin \ |
| 109 | + && rm -rf docker.tgz docker |
| 110 | + |
| 111 | +# Install perfcollect |
| 112 | +ADD https://raw.githubusercontent.com/microsoft/perfview/main/src/perfcollect/perfcollect /usr/bin/perfcollect |
| 113 | +RUN chmod +x /usr/bin/perfcollect |
| 114 | +RUN /usr/bin/perfcollect install |
| 115 | + |
| 116 | +COPY --from=build-env /app /app |
| 117 | + |
| 118 | +ENTRYPOINT [ "/app/crank-agent" ] |
0 commit comments