-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build the Docker images can take 10+ minutes #2426
Comments
I was about to write a similar issue today since I managed to reduce the build time from 8+ minutes to 3+ minutes by hacking the code a bit. I think we could even reduce the build time further to 1 minute with a few more modifications. Spoiler alert there is also an I managed these performance improvements with these steps:
Additionally, most of the time was spent downloading the beats one by one. We could add this step to further reduce the build time: I will analyze each step one by one:
For example one of those rules for the - os: linux
arch: arm64
types: [docker]
spec:
<<: *agent_docker_arm_spec
<<: *docker_arm_ubi_spec
<<: *elastic_docker_spec
<<: *elastic_license_for_binaries
files:
'{{.BeatName}}{{.BinaryExt}}':
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} In order to only build for
I am not suggesting that commenting on a file is a long-term solution but we should think of
while if when
I am not very familiar with this code but I don't think those two if-branches are doing the same thing. This is because some of those "beats" like Since I wanted to avoid building the beats from the source (since it takes 28 minutes on my laptop), and I didn't need those extra beats I only built for Similarly to step
I started implementing the parallelization of this code with go functions but unfortunately, the function at Line 816 in 1235791
I have a feature branch with the previous changes that work for me at https://github.com/gsantoro/elastic-agent/tree/feature/dev-tools-k8s. |
We definitely need a nicer way to filter down the list of docker images that get built. We can probably just add an environment variable that lets you specify exactly what gets downloaded. Like
Yes when EXTERNAL=false it looks for the beats repo to exist at the same level as the elastic agent repository and either takes the existing beats packages from it or runs It would probably be more valuable to allow There is also the DROP_PATH variable that allows you to manually construct the directory binaries will be sourced from, but when constantly changing branches and versions this is a pain to maintain. It's not quite automatic enough. |
@blakerouse Would your recent improvements via #5338 resolve this issue? |
On my M1 MacOS Monterey system building the agent docker target takes 10+ minutes. The command to do this is:
DEV=true EXTERNAL=true SNAPSHOT=true PLATFORMS=linux/arm64 PACKAGES=docker mage -v package
This builds at least three docker images: elastic-agent, elastic-agent-cloud, and elastic-agent-complete. Usually only one of these is actually needed so adding an option to control which ones are built would help this.
The text was updated successfully, but these errors were encountered: