From e06c01db40e060e29a15a5f80d53ac2688b55bca Mon Sep 17 00:00:00 2001 From: Denis Rechkunov Date: Thu, 19 Dec 2024 15:20:26 +0100 Subject: [PATCH] Build only cloud image variant when it's requested 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. --- magefile.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/magefile.go b/magefile.go index 1e3839d125..7a916035b7 100644 --- a/magefile.go +++ b/magefile.go @@ -84,6 +84,7 @@ const ( externalArtifacts = "EXTERNAL" platformsEnv = "PLATFORMS" packagesEnv = "PACKAGES" + dockerVariants = "DOCKER_VARIANTS" configFile = "elastic-agent.yml" agentDropPath = "AGENT_DROP_PATH" checksumFilename = "checksum.yml" @@ -782,9 +783,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 @@ -798,6 +803,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