Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 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-fleets-ubuntu-2204-1770381074"
IMAGE_UBUNTU_ARM_64: "platform-ingest-fleet-server-ubuntu-2204-aarch64-1770381074"

# 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 @@ -91,7 +91,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 +106,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 +122,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 +139,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 Down
10 changes: 5 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-1767879728"
IMAGE_UBUNTU_ARM_64: "platform-ingest-elastic-agent-ubuntu-2204-aarch64-1767879728"
IMAGE_UBUNTU_X86_64_FIPS: "platform-ingest-fleet-server-ubuntu-2204-fips"
IMAGE_UBUNTU_X86_64: "platform-ingest-fleets-ubuntu-2204-1770381074"
IMAGE_UBUNTU_ARM_64: "platform-ingest-fleet-server-ubuntu-2204-aarch64-1770381074"
IMAGE_UBUNTU_X86_64_FIPS: "platform-ingest-fleet-server-ubuntu-2204-fips-1770381074"

# 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 @@ -173,7 +173,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 +187,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 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