Skip to content
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

fix: generate complete variant binaries properly #27609

Closed
10 changes: 4 additions & 6 deletions dev-tools/mage/dockerbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ func (b *dockerBuilder) Build() error {
return errors.Wrap(err, "failed to prepare build")
}

tag, err := b.dockerBuild(variant)
tag, err := b.dockerBuild()
tries := 3
for err != nil && tries != 0 {
fmt.Println(">> Building docker images again (after 10 s)")
// This sleep is to avoid hitting the docker build issues when resources are not available.
time.Sleep(time.Second * 10)
tag, err = b.dockerBuild(variant)
tag, err = b.dockerBuild()
tries -= 1
}
if err != nil {
Expand Down Expand Up @@ -194,11 +194,9 @@ func (b *dockerBuilder) expandDockerfile(templatesDir string, data map[string]in
return nil
}

func (b *dockerBuilder) dockerBuild(variant string) (string, error) {
func (b *dockerBuilder) dockerBuild() (string, error) {
imageName := b.imageName
if variant != "" {
imageName = fmt.Sprintf("%s-%s", imageName, variant)
}

taggedImageName := fmt.Sprintf("%s:%s", imageName, b.Version)
if b.Snapshot {
taggedImageName = taggedImageName + "-SNAPSHOT"
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/mage/pkgtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const (
packageStagingDir = "build/package"

// defaultBinaryName specifies the output file for zip and tar.gz.
defaultBinaryName = "{{.Name}}-{{if .Variant}}{{.Variant}}-{{end}}{{.Version}}{{if .Snapshot}}-SNAPSHOT{{end}}{{if .OS}}-{{.OS}}{{end}}{{if .Arch}}-{{.Arch}}{{end}}"
defaultBinaryName = "{{.Name}}-{{.Version}}{{if .Snapshot}}-SNAPSHOT{{end}}{{if .OS}}-{{.OS}}{{end}}{{if .Arch}}-{{.Arch}}{{end}}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Variant is not needed anymore here, I guess that the rest of #27621 can be reverted too?

)

// PackageType defines the file format of the package (e.g. zip, rpm, etc).
Expand Down
29 changes: 29 additions & 0 deletions dev-tools/packaging/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ shared:
from: 'arm64v8/centos:7'
buildFrom: 'arm64v8/centos:7'

- &agent_docker_complete_spec
extra_vars:
dockerfile: 'Dockerfile.elastic-agent.tmpl'
image_name: '{{.BeatName}}-complete'

# Deb/RPM spec for community beats.
- &deb_rpm_spec
<<: *common
Expand Down Expand Up @@ -1000,6 +1005,18 @@ specs:
<<: *agent_docker_spec
<<: *elastic_docker_spec
<<: *elastic_license_for_binaries
files:
'{{.BeatName}}{{.BinaryExt}}':
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}}

- os: linux
arch: amd64
types: [docker]
spec:
<<: *agent_docker_spec
<<: *agent_docker_complete_spec
<<: *elastic_docker_spec
<<: *elastic_license_for_binaries
# This image gets a 'complete' variant for synthetics and other large
# packages too big to fit in the main image
variants: ["complete"]
Expand All @@ -1026,6 +1043,18 @@ specs:
<<: *agent_docker_arm_spec
<<: *elastic_docker_spec
<<: *elastic_license_for_binaries
files:
'{{.BeatName}}{{.BinaryExt}}':
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}}

- os: linux
arch: arm64
types: [docker]
spec:
<<: *agent_docker_arm_spec
<<: *agent_docker_complete_spec
<<: *elastic_docker_spec
<<: *elastic_license_for_binaries
# This image gets a 'complete' variant for synthetics and other large
# packages too big to fit in the main image
variants: ["complete"]
Expand Down
4 changes: 2 additions & 2 deletions x-pack/elastic-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ If you are in the 7.13 branch, this will create the `docker.elastic.co/beats/ela
elastic-package stack up --version=7.13.0-SNAPSHOT -v
```

Please note that the docker container is built in both standard and 'offline' variants.
The 'offline' variant contains extra files, like the chromium browser, that are too large
Please note that the docker container is built in both standard and 'complete' variants.
The 'complete' variant contains extra files, like the chromium browser, that are too large
for the standard variant.