Make beyla-genfiles self-contained#1767
Conversation
| export BPF_CFLAGS="-O2 -g -Wall -Werror" | ||
| export BEYLA_GENFILES_RUN_LOCALLY=1 | ||
| go run cmd/beyla-genfiles/beyla_genfiles.go | ||
| beyla_genfiles |
There was a problem hiding this comment.
The previous approach of calling go run will not work on downstream projects pulling Beyla
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1767 +/- ##
==========================================
- Coverage 67.01% 66.98% -0.04%
==========================================
Files 219 219
Lines 22616 22632 +16
==========================================
+ Hits 15157 15159 +2
- Misses 6691 6705 +14
Partials 768 768
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
0f10751 to
caf9792
Compare
mariomac
left a comment
There was a problem hiding this comment.
I don't get why we need removing the env package (increasing our code surface instead of relying on a stable library that is used in other parts of our code).
If you want to build beyla_genfiles, you can just do, from the project root:
go build -o beyla_genfiles cmd/beyla-genfiles/beyla_genfiles.go
Which already contains the go.mod and vendored dependencies.
generator.Dockerfile
Outdated
| COPY cmd/beyla-genfiles/beyla_genfiles.go . | ||
| RUN go build -o /go/bin/beyla_genfiles beyla_genfiles.go | ||
| RUN go clean -modcache -cache | ||
| RUN rm beyla_genfiles.go |
There was a problem hiding this comment.
You probably can just copy the whole project, build the project with:
go build -o beyla_genfiles cmd/beyla-genfiles/beyla_genfiles.go
Then, below, instead of FROM base AS builder, do something like:
FROM alpine
COPY --from=base /path/beyla_genfiles .
There was a problem hiding this comment.
Actually you should also move this to the FROM alpine section:
RUN apk add clang llvm19 curl
RUN apk cache purge
And copy the bpf2go command also here.
There was a problem hiding this comment.
Maybe then is simpler to just keep it as you have it now 🤣
There was a problem hiding this comment.
Hehee nah, that (having an intermediate step and copying the resulting artefacts as you suggest) makes sense indeed. I will look into it.
So, with regards to the dependency on the env package, it was mostly because Alloy does:
go run github.com/grafana/beyla/v2/cmd/beyla-genfiles@main
was giving me issues (the go tool was complaining it could not pull the env dependency). Let me run another tests with the dependency back in place and see how it goes.
There was a problem hiding this comment.
@mariomac ok I've updated the PR, seems to work for Alloy - I've incorporated all of your suggestions (hopefully, let me know if I missed anything) and it looks better now IMHO.
99a4e28 to
62c78aa
Compare
This PR embeds the
beyla-genfilebinary in the generator image, to allow downstream software vendoring Beyla to run this tool without having to explicitly fetch its source code and provide it to the image (that only works when building beyla itself, as tools are not distributed as vendored modules).This relates to grafana/alloy#2734