Skip to content
18 changes: 12 additions & 6 deletions .buildkite/pipeline.package.mbp.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
name: "fleet server package mbp"
env:
IMAGE_UBUNTU_X86_64: "family/core-ubuntu-2204"
IMAGE_UBUNTU_ARM_64: "core-ubuntu-2204-aarch64"
IMAGE_UBUNTU_X86_64: "platform-ingest-fleet-server-ubuntu-2204-1772547557"
IMAGE_UBUNTU_ARM_64: "test-platform-ingest-fleet-server-ubuntu-2204-aarch64-1772547557"

# This section is used to define the plugins that will be used in the pipeline.
# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins
Expand Down Expand Up @@ -32,6 +32,7 @@ steps:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"
imageProject: "elastic-images-qa"
artifact_paths:
- build/distributions/**
plugins:
Expand All @@ -46,6 +47,7 @@ steps:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"
imageProject: "elastic-images-qa"
artifact_paths:
- build/distributions/**
plugins:
Expand All @@ -62,6 +64,7 @@ steps:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"
imageProject: "elastic-images-qa"
artifact_paths:
- build/distributions/**
plugins:
Expand All @@ -79,6 +82,7 @@ steps:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"
imageProject: "elastic-images-qa"
artifact_paths:
- build/distributions/**
plugins:
Expand All @@ -91,7 +95,7 @@ steps:
command: ".buildkite/scripts/package.sh snapshot"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
image: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "t4g.2xlarge"
artifact_paths:
- build/distributions/**
Expand All @@ -106,7 +110,7 @@ steps:
.buildkite/scripts/package.sh staging
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
image: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "t4g.2xlarge"
artifact_paths:
- build/distributions/**
Expand All @@ -122,7 +126,7 @@ steps:
FIPS: "true"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
image: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "t4g.2xlarge"
artifact_paths:
- build/distributions/**
Expand All @@ -139,7 +143,7 @@ steps:
FIPS: "true"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
image: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "t4g.2xlarge"
artifact_paths:
- build/distributions/**
Expand All @@ -155,6 +159,7 @@ steps:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"
imageProject: "elastic-images-qa"
plugins:
- *oidc_plugin
- *docker_elastic_login_plugin
Expand All @@ -180,6 +185,7 @@ steps:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"
imageProject: "elastic-images-qa"
plugins:
- *oidc_plugin
- *docker_elastic_login_plugin
Expand Down
14 changes: 9 additions & 5 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
env:
DOCKER_COMPOSE_VERSION: "1.25.5"
TERRAFORM_VERSION: "1.6.4"
IMAGE_UBUNTU_X86_64: "platform-ingest-elastic-agent-ubuntu-2204-1772525581"
IMAGE_UBUNTU_ARM_64: "platform-ingest-elastic-agent-ubuntu-2204-aarch64-1772525581"
IMAGE_UBUNTU_X86_64_FIPS: "platform-ingest-fleet-server-ubuntu-2204-fips"
IMAGE_UBUNTU_X86_64: "platform-ingest-fleet-server-ubuntu-2204-1772547557"
IMAGE_UBUNTU_ARM_64: "test-platform-ingest-fleet-server-ubuntu-2204-aarch64-1772547557"
IMAGE_UBUNTU_X86_64_FIPS: "test-platform-ingest-fleet-server-ubuntu-2204-fips-1772547557"

# This section is used to define the plugins that will be used in the pipeline.
# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins
Expand Down Expand Up @@ -59,6 +59,7 @@ steps:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"
imageProject: "elastic-images-qa"
plugins:
- *oidc_plugin
- *dockerhub_login_plugin
Expand All @@ -75,6 +76,7 @@ steps:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"
imageProject: "elastic-images-qa"
plugins:
- *oidc_plugin
- *dockerhub_login_plugin
Expand Down Expand Up @@ -173,7 +175,7 @@ steps:
GO_DISTRO: "microsoft"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_X86_64_FIPS}"
image: "${IMAGE_UBUNTU_X86_64_FIPS}"
instanceType: "m5.xlarge"
artifact_paths:
- build/*.xml
Expand All @@ -187,7 +189,7 @@ steps:
GO_DISTRO: "stdlib"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_X86_64_FIPS}"
image: "${IMAGE_UBUNTU_X86_64_FIPS}"
instanceType: "m5.xlarge"
artifact_paths:
- build/*.xml
Expand All @@ -210,6 +212,7 @@ steps:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"
imageProject: "elastic-images-qa"
artifact_paths:
- build/*.xml
plugins:
Expand All @@ -228,6 +231,7 @@ steps:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "c2-standard-16"
imageProject: "elastic-images-qa"
artifact_paths:
- build/*.xml
- build/e2e-coverage.out
Expand Down
64 changes: 53 additions & 11 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ func (Build) Local() error {
outFile = filepath.Join("bin", binaryExe)

}
return sh.RunWithV(env, "go", "build", "-tags="+getTagsString(), "-gcflags="+getGCFlags(), "-ldflags="+getLDFlags(), "-o", outFile, ".")
return sh.RunWithV(env, "go", "build", "-buildvcs=false", "-tags="+getTagsString(), "-gcflags="+getGCFlags(), "-ldflags="+getLDFlags(), "-o", outFile, ".")
}

// Binary builds release binaries for the specified platforms.
Expand Down Expand Up @@ -753,6 +753,7 @@ func goBuild(osArg, archArg string, cover bool) error {

args := []string{
"build",
"-buildvcs=false",
"-tags=" + getTagsString(),
"-gcflags=" + getGCFlags(),
"-ldflags=" + getLDFlags(),
Expand Down Expand Up @@ -973,6 +974,8 @@ func (Docker) Release() error {
}

// dockerRun runs the target on a container produced by docker:builder.
// When .git/objects/info/alternates exists and points to paths on the host (e.g. CI git mirrors),
// those paths are mounted into the container at the same location so Go's VCS stamping can read them.
func dockerRun(target string) error {
userInfo, err := user.Current()
if err != nil {
Expand All @@ -982,17 +985,56 @@ func dockerRun(target string) error {
if err != nil {
return fmt.Errorf("unable to get wd: %w", err)
}
return sh.RunV("docker", "run", "--rm",
"-u", userInfo.Uid+":"+userInfo.Gid,
args := []string{"run", "--rm",
"-u", userInfo.Uid + ":" + userInfo.Gid,
"--env=GOCACHE=/go/cache",
"--volume", pwd+":/fleet-server/",
"-e", envPlatforms+"="+strings.Join(getPlatforms(), ","),
"-e", envDev+"="+strconv.FormatBool(isDEV()),
"-e", envFIPS+"="+strconv.FormatBool(isFIPS()),
"-e", envSnapshot+"="+strconv.FormatBool(isSnapshot()),
"-e", envVersionQualifier+"="+os.Getenv(envVersionQualifier),
dockerBuilderName+":"+getGoVersion(), target,
)
"--volume", pwd + ":/fleet-server/",
"-e", envPlatforms + "=" + strings.Join(getPlatforms(), ","),
"-e", envDev + "=" + strconv.FormatBool(isDEV()),
"-e", envFIPS + "=" + strconv.FormatBool(isFIPS()),
"-e", envSnapshot + "=" + strconv.FormatBool(isSnapshot()),
"-e", envVersionQualifier + "=" + os.Getenv(envVersionQualifier),
}
for _, vol := range gitAlternatesVolumeMounts() {
args = append(args, "--volume", vol)
}
args = append(args, dockerBuilderName+":"+getGoVersion(), target)
return sh.RunV("docker", args...)
}

// gitAlternatesVolumeMounts returns docker --volume args for paths listed in
// .git/objects/info/alternates that exist on the host, so the container can
// access them at the same path (required for Go VCS stamping when using git alternates).
func gitAlternatesVolumeMounts() []string {
alternatesPath := filepath.Join(".git", "objects", "info", "alternates")
data, err := os.ReadFile(alternatesPath)
if err != nil {
return nil
}
infoDir := filepath.Dir(alternatesPath)
var mounts []string
scanner := bufio.NewScanner(bytes.NewReader(data))
for scanner.Scan() {
path := strings.TrimSpace(scanner.Text())
if path == "" || strings.HasPrefix(path, "#") {
continue
}
// Path in alternates is relative to .git/objects/info or absolute.
if !filepath.IsAbs(path) {
path = filepath.Join(infoDir, path)
}
path, err = filepath.Abs(path)
if err != nil {
continue
}
info, err := os.Stat(path)
if err != nil || !info.IsDir() {
continue
}
// Mount host path to same path in container so Go's VCS resolution works.
mounts = append(mounts, path+":"+path)
}
return mounts
}

// Binary builds binaries within a docker image produced by docker:builder.
Expand Down
Loading