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

[YUNIKORN-2874] Fix reproducible builds when a release is generated #914

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ endif

# Make sure we are in the same directory as the Makefile
BASE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
PARENT_DIR := $(dir $(abspath $(BASE_DIR)/..))
craigcondit marked this conversation as resolved.
Show resolved Hide resolved

# Output directories
OUTPUT=build
Expand Down Expand Up @@ -89,6 +90,16 @@ else
REPRO :=
endif

# Release build requires using parent dir as base for buildroot
RELEASE_BUILD := $(test -f "$(BASE_DIR)/.gitignore" ; echo $?)
craigcondit marked this conversation as resolved.
Show resolved Hide resolved
ifeq ($(RELEASE_BUILD),1)
DOCKER_BUILDROOT := $(shell cd "$(BASE_DIR)/.." ; pwd)
DOCKER_SRCROOT := /buildroot/k8shim
else
DOCKER_BUILDROOT := $(shell cd "$(BASE_DIR)" ; pwd)
DOCKER_SRCROOT := /buildroot
endif

# Build date - Use git commit, then cached build.date, finally current date
# This allows for reproducible builds as long as release tarball contains the build.date file.
DATE := $(shell if [ -d "$(BASE_DIR)/.git" ]; then TZ=UTC0 git --no-pager log -1 --date=iso8601-strict-local --format=%cd 2>/dev/null ; fi || true)
Expand Down Expand Up @@ -440,7 +451,7 @@ $(RELEASE_BIN_DIR)/$(SCHEDULER_BINARY): go.mod go.sum $(shell find pkg)
@echo "building binary for scheduler docker image"
@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 && \
docker run -t --rm=true --volume "$(DOCKER_BUILDROOT):/buildroot" "golang:$(GO_REPRO_VERSION)" sh -c "cd $(DOCKER_SRCROOT) && \
CGO_ENABLED=0 GOOS=linux GOARCH=\"${EXEC_ARCH}\" go build \
-a \
-o=${RELEASE_BIN_DIR}/${SCHEDULER_BINARY} \
Expand Down Expand Up @@ -468,7 +479,7 @@ $(RELEASE_BIN_DIR)/$(PLUGIN_BINARY): go.mod go.sum $(shell find pkg)
@echo "building binary for plugin docker image"
@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 && \
docker run -t --rm=true --volume "$(DOCKER_BUILDROOT):/buildroot" "golang:$(GO_REPRO_VERSION)" sh -c "cd $(DOCKER_SRCROOT) && \
CGO_ENABLED=0 GOOS=linux GOARCH=\"${EXEC_ARCH}\" go build \
-a \
-o=${RELEASE_BIN_DIR}/${PLUGIN_BINARY} \
Expand Down Expand Up @@ -555,7 +566,7 @@ $(RELEASE_BIN_DIR)/$(ADMISSION_CONTROLLER_BINARY): go.mod go.sum $(shell find pk
@echo "building admission controller 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 && \
docker run -t --rm=true --volume "$(DOCKER_BUILDROOT):/buildroot" "golang:$(GO_REPRO_VERSION)" sh -c "cd $(DOCKER_SRCROOT) && \
CGO_ENABLED=0 GOOS=linux GOARCH=\"${EXEC_ARCH}\" go build \
-a \
-o=$(RELEASE_BIN_DIR)/$(ADMISSION_CONTROLLER_BINARY) \
Expand Down