Skip to content

Commit 3903879

Browse files
fix(build): resolve kustomize installation failures during cross-compilation
- Build kustomize in isolated temporary directory to avoid module conflicts - Ensure binary is placed at /go/bin/kustomize for Docker verification step Fixes Docker build failures in GoReleaser pipeline when cross-compiling for different target architectures. Closes viaduct-ai#298
1 parent c58ac0b commit 3903879

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

scripts/install-kustomize.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,23 @@ function install_kustomize() {
1616
KSOPS_VERSION=$KSOPS_TAG
1717
fi
1818
LDFLAGS+=" -X sigs.k8s.io/kustomize/api/provenance.version=${KUSTOMIZE_VERSION}+ksops.${KSOPS_VERSION}"
19-
GO111MODULE=on go install -ldflags "${LDFLAGS}" sigs.k8s.io/kustomize/kustomize/$KUSTOMIZE_MAJOR_VERSION@$KUSTOMIZE_VERSION
2019

21-
# Print the go binary path
22-
GO_PATH=$(go env GOPATH)
23-
KUSTOMIZE_PATH="$GO_PATH/bin/$KUSTOMIZE"
20+
# Build kustomize in a temporary directory to avoid module conflicts
21+
TEMP_DIR=$(mktemp -d)
22+
cd "$TEMP_DIR"
23+
24+
# Initialize a temporary module
25+
go mod init temp-kustomize-build
26+
GO111MODULE=on go get sigs.k8s.io/kustomize/kustomize/$KUSTOMIZE_MAJOR_VERSION@$KUSTOMIZE_VERSION
27+
GO111MODULE=on go build -ldflags "${LDFLAGS}" -o /go/bin/kustomize sigs.k8s.io/kustomize/kustomize/$KUSTOMIZE_MAJOR_VERSION
28+
29+
# Clean up temp directory
30+
cd - > /dev/null
31+
rm -rf "$TEMP_DIR"
32+
33+
KUSTOMIZE_PATH="/go/bin/kustomize"
2434
echo "kustomize installed at $KUSTOMIZE_PATH"
25-
35+
2636
$KUSTOMIZE_PATH version
2737
}
2838

@@ -37,7 +47,7 @@ if [ -x "$(command -v $KUSTOMIZE)" ]; then
3747
# Remove existing kustomize executable
3848
echo "Removing existing $KUSTOMIZE executable..."
3949
echo "rm $KUSTOMIZE_EXEC"
40-
rm $KUSTOMIZE_EXEC
50+
rm "$KUSTOMIZE_EXEC"
4151

4252
# Install
4353
install_kustomize

0 commit comments

Comments
 (0)