From 7edf154480faa62027eea83f623d7ed27f5bdfe7 Mon Sep 17 00:00:00 2001 From: Pau Capdevila Date: Tue, 3 Feb 2026 12:58:47 +0100 Subject: [PATCH] build iperf 3.20 Signed-off-by: Pau Capdevila --- Dockerfile | 18 ++++++++++++++++-- packages_build.sh | 28 ++++++++++++++++++++++++++++ packages.sh => packages_runtime.sh | 8 ++------ 3 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 packages_build.sh rename packages.sh => packages_runtime.sh (92%) mode change 100755 => 100644 diff --git a/Dockerfile b/Dockerfile index 9dc547a..8aeb1a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,23 @@ # Copyright 2025 Hedgehog # SPDX-License-Identifier: Apache-2.0 -FROM ubuntu:noble +FROM ubuntu:noble AS builder +RUN --mount=type=bind,source=packages_build.sh,target=/tmp/packages_build.sh /bin/bash /tmp/packages_build.sh -RUN --mount=type=bind,source=packages.sh,target=/tmp/packages.sh /tmp/packages.sh +FROM golang:alpine AS go_builder +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN CGO_ENABLED=0 GOOS=linux go build -o /app/bin/version ./cmd/version +RUN CGO_ENABLED=0 GOOS=linux go build -o /app/bin/demo ./cmd/demo + +FROM ubuntu:noble AS runner +RUN --mount=type=bind,source=packages_runtime.sh,target=/tmp/packages_runtime.sh /bin/bash /tmp/packages_runtime.sh + +COPY --from=builder /usr/local/bin/iperf3 /usr/local/bin/iperf3 +COPY --from=builder /usr/local/lib/libiperf.so* /usr/local/lib/ +RUN ldconfig WORKDIR / COPY --chown=0:0 ./bin/version /bin/ diff --git a/packages_build.sh b/packages_build.sh new file mode 100644 index 0000000..8681659 --- /dev/null +++ b/packages_build.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Copyright 2025 Hedgehog +# SPDX-License-Identifier: Apache-2.0 + +set -eux +set -o pipefail + +BUILD_APT_PACKAGES=( + ca-certificates + git + build-essential + libtool + autoconf + automake + pkg-config +) + +apt-get update -y \ + && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes \ + "${BUILD_APT_PACKAGES[@]}" \ + && rm -rf /var/lib/apt/lists/* + +git clone https://github.com/esnet/iperf.git /tmp/iperf \ + && cd /tmp/iperf \ + && ./configure \ + && make \ + && make install \ + && cd / diff --git a/packages.sh b/packages_runtime.sh old mode 100755 new mode 100644 similarity index 92% rename from packages.sh rename to packages_runtime.sh index 2c953bf..e527829 --- a/packages.sh +++ b/packages_runtime.sh @@ -2,15 +2,13 @@ # Copyright 2025 Hedgehog # SPDX-License-Identifier: Apache-2.0 - set -eux set -o pipefail -APT_PACKAGES=( +RUNTIME_APT_PACKAGES=( curl dhcping ethtool - iperf3 iproute2 iputils-ping net-tools @@ -21,8 +19,6 @@ APT_PACKAGES=( traceroute wget vim - curl - wget pciutils ca-certificates tshark @@ -45,7 +41,7 @@ APT_PACKAGES=( apt-get update -y \ && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes \ - "${APT_PACKAGES[@]}" \ + "${RUNTIME_APT_PACKAGES[@]}" \ && apt-get clean autoclean \ && apt-get autoremove --yes \ && rm -rf /var/lib/apt/lists/*