Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
28 changes: 28 additions & 0 deletions packages_build.sh
Original file line number Diff line number Diff line change
@@ -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 /
8 changes: 2 additions & 6 deletions packages.sh → packages_runtime.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,8 +19,6 @@ APT_PACKAGES=(
traceroute
wget
vim
curl
wget
pciutils
ca-certificates
tshark
Expand All @@ -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/*
Expand Down