This is an automated email from the ASF dual-hosted git repository.
ccondit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-web.git
The following commit(s) were added to refs/heads/master by this push:
new 8c2b795 [YUNIKORN-2486] Web: Use Docker to build reproducible
binaries (#179)
8c2b795 is described below
commit 8c2b7958d81330f74285b5a6af13c6b9ba2d4aa3
Author: Craig Condit <[email protected]>
AuthorDate: Fri Mar 15 09:35:59 2024 -0500
[YUNIKORN-2486] Web: Use Docker to build reproducible binaries (#179)
Introduces a build var (REPRODUCIBLE_BUILDS=1) to force building
binaries using Docker. This results in builds with a consistent
environment every time.
Closes: #179
---
.gitignore | 1 +
.go_repro_version | 1 +
Makefile | 17 +++++++++++++++++
3 files changed, 19 insertions(+)
diff --git a/.gitignore b/.gitignore
index 6c0c268..065066f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,7 @@ yarn-error.log
.classpath
.c9/
*.launch
+*.swp
.settings/
*.sublime-workspace
diff --git a/.go_repro_version b/.go_repro_version
new file mode 100644
index 0000000..428abfd
--- /dev/null
+++ b/.go_repro_version
@@ -0,0 +1 @@
+1.21.8
diff --git a/Makefile b/Makefile
index 86d5580..cec163d 100644
--- a/Makefile
+++ b/Makefile
@@ -72,6 +72,14 @@ ifeq ($(REGISTRY),)
REGISTRY := apache
endif
+# Reproducible builds mode
+GO_REPRO_VERSION := $(shell cat .go_repro_version)
+ifeq ($(REPRODUCIBLE_BUILDS),1)
+ REPRO := 1
+else
+ REPRO :=
+endif
+
# Set the default web port
PORT=9889
@@ -233,11 +241,20 @@ build_server_prod: $(RELEASE_BIN_DIR)/$(SERVER_BINARY)
$(RELEASE_BIN_DIR)/$(SERVER_BINARY): go.mod go.sum $(shell find pkg)
@echo "building web server binary"
@mkdir -p ${RELEASE_BIN_DIR}
+ifeq ($(REPRO),1)
+ docker run -t --rm=true --volume "$(BASE_DIR):/buildroot"
"golang:$(GO_REPRO_VERSION)" sh -c "cd /buildroot && \
+ CGO_ENABLED=0 GOOS=linux GOARCH=\"${EXEC_ARCH}\" \
+ go build -a -o=${RELEASE_BIN_DIR}/${SERVER_BINARY} -trimpath -ldflags \
+ '-buildid= -extldflags \"-static\" -X main.version=${VERSION} -X
main.date=${DATE}' \
+ -tags netgo -installsuffix netgo \
+ ./pkg/cmd/web/"
+else
CGO_ENABLED=0 GOOS=linux GOARCH="${EXEC_ARCH}" \
"$(GO)" build -a -o=${RELEASE_BIN_DIR}/${SERVER_BINARY} -trimpath
-ldflags \
'-buildid= -extldflags "-static" -X main.version=${VERSION} -X
main.date=${DATE}' \
-tags netgo -installsuffix netgo \
./pkg/cmd/web/
+endif
# Run the web interface from the production image
.PHONY: run
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]