Browse code

hack/make/.binary: use with-go-mod.sh

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>

Bjorn Neergaard authored on 2023/07/11 22:36:17
Showing 1 changed files
... ...
@@ -74,19 +74,11 @@ source "${MAKEDIR}/.go-autogen"
74 74
 		fi
75 75
 	fi
76 76
 
77
-	# This is a workaround to have buildinfo with deps embedded in the binary. We
78
-	# need to create a go.mod file before building with -modfile=vendor.mod,
79
-	# otherwise it fails with: "-modfile cannot be used to set the module root directory."
80
-	if [ ! -f "go.mod" ]; then
81
-		printf '%s\n\n%s' 'module github.com/docker/docker' 'go 1.19' > "go.mod"
82
-		trap 'rm -f go.mod' EXIT
83
-	fi
84
-
85 77
 	echo "Building $([ "$DOCKER_STATIC" = "1" ] && echo "static" || echo "dynamic") $DEST/$BINARY_FULLNAME ($PLATFORM_NAME)..."
86 78
 	if [ -n "$DOCKER_DEBUG" ]; then
87 79
 		set -x
88 80
 	fi
89
-	GO111MODULE=on go build -mod=vendor -modfile=vendor.mod -o "$DEST/$BINARY_FULLNAME" "${BUILDFLAGS[@]}" -ldflags "$LDFLAGS $LDFLAGS_STATIC $DOCKER_LDFLAGS" ${GO_PACKAGE}
81
+	./hack/with-go-mod.sh go build -mod=vendor -modfile=vendor.mod -o "$DEST/$BINARY_FULLNAME" "${BUILDFLAGS[@]}" -ldflags "$LDFLAGS $LDFLAGS_STATIC $DOCKER_LDFLAGS" "$GO_PACKAGE"
90 82
 )
91 83
 
92 84
 echo "Created binary: $DEST/$BINARY_FULLNAME"