Skip to content

Commit

Permalink
Update generator image
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelroquetto committed Feb 14, 2025
1 parent b8d1e12 commit 9f3b0fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ IMG = $(IMG_REGISTRY)/$(IMG_ORG)/$(IMG_NAME):$(VERSION)

# The generator is a container image that provides a reproducible environment for
# building eBPF binaries
GEN_IMG ?= ghcr.io/grafana/beyla-generator:main
GEN_IMG ?= ghcr.io/grafana/beyla-ebpf-generator:main

COMPOSE_ARGS ?= -f test/integration/docker-compose.yml

Expand Down
54 changes: 14 additions & 40 deletions generator.Dockerfile
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"]

0 comments on commit 9f3b0fe

Please # to comment.