Skip to content

Commit 665d824

Browse files
committed
Add go buildflag -trimpath to also make go binary reproducible outside of Docker
1 parent b0c1e66 commit 665d824

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

.github/workflows/create-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Install depends
3737
run: go get .
3838
- name: Build
39-
run: go build -v -o ${{ steps.repo.outputs.repo }}-${{ steps.version.outputs.version }}-${{ matrix.os }}-${{ matrix.arch }}
39+
run: go build -v -trimpath -o ${{ steps.repo.outputs.repo }}-${{ steps.version.outputs.version }}-${{ matrix.os }}-${{ matrix.arch }}
4040
- name: Generate artifact attestation
4141
uses: actions/attest@v4
4242
with:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN go mod download && go mod verify
1010
COPY . .
1111
# To make reproducible the `COPY --from=builder` layer reproducible, we set modification time to build timestamp
1212
# and we will copy the directory at once to avoid /usr/local/bin being "created" instead of copied (resulting in wrong a newer modification time).
13-
RUN CGO_ENABLED=0 go build -o /usr/local/bin/ue-lite && touch --no-dereference --date="@$(ue-lite --build-timestamp)" /usr/local/bin /usr/local/bin/ue-lite
13+
RUN CGO_ENABLED=0 go build -trimpath -o /usr/local/bin/ue-lite && touch --no-dereference --date="@$(ue-lite --build-timestamp)" /usr/local/bin /usr/local/bin/ue-lite
1414

1515
FROM alpine:3.23.3
1616
COPY --from=builder /usr/local/bin /usr/local/bin

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ MKDIRP = mkdir -p
1111
.PHONY: install uninstall build clean default
1212
default: build
1313
build:
14-
go build
14+
CGO_ENABLED=0 go build -trimpath
1515
clean:
1616
go clean
1717
reinstall: uninstall install

0 commit comments

Comments
 (0)