-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8d1e12
commit 9f3b0fe
Showing
2 changed files
with
15 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,25 @@ | ||
FROM ubuntu:oracular AS base | ||
|
||
ARG GOVERSION="1.23.3" | ||
|
||
ARG TARGETARCH | ||
|
||
RUN echo "using TARGETARCH: $TARGETARCH" | ||
FROM golang:alpine3.21 AS base | ||
|
||
# Installs dependencies that are required to compile eBPF programs | ||
RUN apt update -y | ||
RUN apt install -y curl git linux-headers-generic make llvm clang unzip libbpf-dev libbpf-tools linux-libc-dev linux-bpf-dev | ||
RUN apt clean | ||
RUN apk add clang llvm19 | ||
RUN apk cache purge | ||
RUN go install github.com/cilium/ebpf/cmd/bpf2go@v0.16.0 | ||
|
||
VOLUME ["/src"] | ||
|
||
WORKDIR / | ||
|
||
# Installs a fairly modern distribution of Go | ||
RUN curl -qL https://go.dev/dl/go$GOVERSION.linux-$TARGETARCH.tar.gz -o go.tar.gz | ||
RUN tar -xzf go.tar.gz | ||
RUN rm go.tar.gz | ||
|
||
ENV GOROOT /go | ||
RUN mkdir -p /gopath | ||
ENV GOPATH /gopath | ||
|
||
ENV GOBIN $GOPATH/bin | ||
ENV PATH $GOROOT/bin:$GOBIN:$PATH | ||
ENV TOOLS_DIR $GOBIN | ||
|
||
WORKDIR /tmp | ||
# Copies some pre-required Go dependencies to avoid downloading them on each build | ||
COPY Makefile Makefile | ||
COPY go.mod go.mod | ||
|
||
RUN make bpf2go | ||
|
||
WORKDIR /src | ||
|
||
# fix some arch-dependant missing include files | ||
FROM base AS base-arm64 | ||
ENV C_INCLUDE_PATH=/usr/include/aarch64-linux-gnu | ||
FROM base AS builder | ||
|
||
FROM base AS base-amd64 | ||
ENV C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu | ||
RUN cat <<EOF > /generate.sh | ||
#!/bin/sh | ||
export BPF2GO=bpf2go | ||
export BPF_CLANG=clang | ||
export BPF_CFLAGS="-O2 -g -Wall -Werror" | ||
grep -rlI "BPF2GO" pkg/internal/ | xargs -P 0 -n 1 go generate | ||
EOF | ||
|
||
# Picks up the arch-specific base | ||
FROM base-$TARGETARCH AS builder | ||
RUN chmod +x /generate.sh | ||
|
||
ENTRYPOINT ["make", "generate"] | ||
ENTRYPOINT ["/generate.sh"] | ||
|