Skip to content

Commit

Permalink
Build only cloud image variant when it's requested (#6408) (#6458)
Browse files Browse the repository at this point in the history
Before this change we were building all possible Docker images to
produce the cloud image. Which is unnecessary and takes a long time.

Now only the `cloud` variant is built.

(cherry picked from commit 63686c4)

Co-authored-by: Denis <[email protected]>
  • Loading branch information
mergify[bot] and rdner authored Jan 3, 2025
1 parent 006a074 commit f89b7a6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const (
externalArtifacts = "EXTERNAL"
platformsEnv = "PLATFORMS"
packagesEnv = "PACKAGES"
dockerVariants = "DOCKER_VARIANTS"
configFile = "elastic-agent.yml"
agentDropPath = "AGENT_DROP_PATH"
checksumFilename = "checksum.yml"
Expand Down Expand Up @@ -778,9 +779,13 @@ func (Cloud) Image(ctx context.Context) {
dev := os.Getenv(devEnv)
defer os.Setenv(devEnv, dev)

variant := os.Getenv(dockerVariants)
defer os.Setenv(dockerVariants, variant)

os.Setenv(platformsEnv, "linux/amd64")
os.Setenv(packagesEnv, "docker")
os.Setenv(devEnv, "true")
os.Setenv(dockerVariants, "cloud")

if s, err := strconv.ParseBool(snapshot); err == nil && !s {
// only disable SNAPSHOT build when explicitely defined
Expand All @@ -794,6 +799,7 @@ func (Cloud) Image(ctx context.Context) {
devtools.DevBuild = true
devtools.Platforms = devtools.Platforms.Filter("linux/amd64")
devtools.SelectedPackageTypes = []devtools.PackageType{devtools.Docker}
devtools.SelectedDockerVariants = []devtools.DockerVariant{devtools.Cloud}

if _, hasExternal := os.LookupEnv(externalArtifacts); !hasExternal {
devtools.ExternalBuild = true
Expand Down

0 comments on commit f89b7a6

Please sign in to comment.