Skip to content

Commit 2c32b51

Browse files
kruskallmergify[bot]
authored andcommitted
fix: ensure clean state when packaging artifacts (#19252)
* 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)
1 parent 266ada8 commit 2c32b51

File tree

5 files changed

+4
-21
lines changed

5 files changed

+4
-21
lines changed

.dockerignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
/build
22
/apm-server
3-
/systemtest
43
/rally
5-
/docs
6-
/testdata

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ testing/smoke/**/main.tf
5353
!testing/smoke/managed/main.tf
5454
testing/rally-cloud/build
5555
.bck
56+
gvm

packaging/docker/Dockerfile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ FROM golang:${GOLANG_VERSION} AS builder
1010
WORKDIR /src
1111
COPY go.mod go.sum /src/
1212
RUN --mount=type=cache,target=/go/pkg/mod go mod download
13-
COPY Makefile *.mk /src/
14-
COPY cmd /src/cmd
15-
COPY internal /src/internal
16-
COPY x-pack /src/x-pack
17-
COPY .git /src/.git
18-
COPY script /src/script
13+
COPY . .
1914

2015
RUN --mount=type=cache,target=/go/pkg/mod \
2116
--mount=type=cache,target=/root/.cache/go-build \

packaging/docker/Dockerfile.fips

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ FROM docker.elastic.co/wolfi/go-msft-fips:${GOLANG_VERSION} as builder
99
WORKDIR /src
1010
COPY go.mod go.sum /src/
1111
RUN --mount=type=cache,target=/root/go/pkg/mod go mod download
12-
COPY Makefile *.mk /src/
13-
COPY cmd /src/cmd
14-
COPY internal /src/internal
15-
COPY x-pack /src/x-pack
16-
COPY .git /src/.git
17-
COPY script /src/script
12+
COPY . .
1813

1914
RUN --mount=type=cache,target=/root/go/pkg/mod \
2015
make apm-server-fips-msft

packaging/docker/Dockerfile.wolfi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ FROM docker.elastic.co/wolfi/go:${GOLANG_VERSION} as builder
99
WORKDIR /src
1010
COPY go.mod go.sum /src/
1111
RUN --mount=type=cache,target=/root/go/pkg/mod go mod download
12-
COPY Makefile *.mk /src/
13-
COPY cmd /src/cmd
14-
COPY internal /src/internal
15-
COPY x-pack /src/x-pack
16-
COPY .git /src/.git
17-
COPY script /src/script
12+
COPY . .
1813

1914
RUN --mount=type=cache,target=/root/go/pkg/mod \
2015
--mount=type=cache,target=/root/.cache/go-build \

0 commit comments

Comments
 (0)