Skip to content

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Nov 4, 2025

Motivation/summary

Go’s build process now automatically embeds VCS information into the
binary. When the repository contains untracked files or the working
tree is dirty, the binary receives a “dirty” flag, which can make it
look tampered, confuse security scanners, and break reproducible
builds.

This PR updates the Dockerfiles to copy the entire repository into the
build image and adds all tracked files to the Docker build context.
By ensuring the same source tree is used both inside and outside the
container, the resulting binary matches the locally‑built version and
the Git state remains clean.

The CI packaging pipeline installs gvm directly in the workspace,
producing a gvm binary that isn’t tracked by Git. Because the file
is untracked, the repository appears dirty, causing Go to embed a
dirty flag in the VCS metadata of the built binary.

This change adds the generated gvm binary to .gitignore,
ensuring the Git tree stays clean and the resulting binary’s VCS
metadata reflects a pristine state.

Checklist

For functional changes, consider:

  • Is it observable through the addition of either logging or metrics?
  • Is its use being published in telemetry to enable product improvement?
  • Have system tests been added to avoid regression?

How to test these changes

  • build docker image
  • inspect apm-server binary and ensure vcs.modified=false

Related issues

Closes #19144


This is an automatic backport of pull request #19252 done by [Mergify](https://mergify.com).

* fix: copy full repository in Docker build to guarantee clean VCS state

Go’s build process now automatically embeds VCS information into the
binary. When the repository contains untracked files or the working
tree is dirty, the binary receives a “dirty” flag, which can make it
look tampered, confuse security scanners, and break reproducible
builds.

This PR updates the Dockerfiles to copy the entire repository into the
build image and adds all tracked files to the Docker build context.
By ensuring the same source tree is used both inside and outside the
container, the resulting binary matches the locally‑built version and
the Git state remains clean.

* fix: add gvm to .gitignore

The CI packaging pipeline installs gvm directly in the workspace,
producing a gvm binary that isn’t tracked by Git. Because the file
is untracked, the repository appears dirty, causing Go to embed a
dirty flag in the VCS metadata of the built binary.

This change adds the generated gvm binary to .gitignore,
ensuring the Git tree stays clean and the resulting binary’s VCS
metadata reflects a pristine state.

* Update Dockerfile

* Update Dockerfile.fips

* Update Dockerfile.wolfi

(cherry picked from commit b74e01a)
@mergify mergify bot requested a review from a team as a code owner November 4, 2025 17:26
@mergify mergify bot added the backport label Nov 4, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@kruskall kruskall enabled auto-merge (squash) November 4, 2025 17:29
@mergify mergify bot added the queued label Nov 4, 2025
mergify bot added a commit that referenced this pull request Nov 4, 2025
@mergify mergify bot merged commit d4b6a74 into 9.2 Nov 4, 2025
23 of 24 checks passed
@mergify mergify bot deleted the mergify/bp/9.2/pr-19252 branch November 4, 2025 17:40
@mergify mergify bot removed the queued label Nov 4, 2025
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

cc @kruskall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants