From 682cae502709468b62e7da471a41acd704d8365b Mon Sep 17 00:00:00 2001 From: Ian Adams Date: Mon, 18 Nov 2024 16:40:38 +0000 Subject: [PATCH] fix: Disable CGO for supervisor and agent builds (#1972) * Disable CGO for supervisor and agent builds * Consolidate CGO_ENABLED=0 flag --- Makefile | 4 ++-- buildscripts/download-dependencies.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4247ecef5..929c1e05f 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ VERSION ?= $(if $(CURRENT_TAG),$(CURRENT_TAG),$(PREVIOUS_TAG)) # Builds the agent for current GOOS/GOARCH pair .PHONY: agent agent: - builder --config="./manifests/observIQ/manifest.yaml" --ldflags "-s -w -X github.com/observiq/bindplane-agent/internal/version.version=$(VERSION)" + CGO_ENABLED=0 builder --config="./manifests/observIQ/manifest.yaml" --ldflags "-s -w -X github.com/observiq/bindplane-agent/internal/version.version=$(VERSION)" mkdir -p $(OUTDIR); cp ./builder/observiq-otel-collector $(OUTDIR)/collector_$(GOOS)_$(GOARCH)$(EXT) # Builds a custom distro for the current GOOS/GOARCH pair using the manifest specified @@ -45,7 +45,7 @@ distro: # Builds the updater for current GOOS/GOARCH pair && sets flags .PHONY: updater updater: - cd ./updater/; go build -ldflags "-s -w\ + cd ./updater/; CGO_ENABLED=0 go build -ldflags "-s -w\ -X 'github.com/observiq/bindplane-agent/updater/internal/version.version=$(VERSION)'\ -X 'github.com/observiq/bindplane-agent/updater/internal/version.gitHash=$(shell git rev-parse HEAD)'\ -X 'github.com/observiq/bindplane-agent/updater/internal/version.date=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")'"\ diff --git a/buildscripts/download-dependencies.sh b/buildscripts/download-dependencies.sh index d70b38fec..b5a64870e 100755 --- a/buildscripts/download-dependencies.sh +++ b/buildscripts/download-dependencies.sh @@ -47,6 +47,6 @@ for PLATFORM in "${PLATFORMS[@]}"; do EXT="" fi echo "Building supervisor for $GOOS/$GOARCH" - GOOS="$GOOS" GOARCH="$GOARCH" go build -o $PROJECT_BASE/$DOWNLOAD_DIR/supervisor_bin/opampsupervisor_${GOOS}_${GOARCH}${EXT} . + GOOS="$GOOS" GOARCH="$GOARCH" CGO_ENABLED=0 go build -o $PROJECT_BASE/$DOWNLOAD_DIR/supervisor_bin/opampsupervisor_${GOOS}_${GOARCH}${EXT} . done $(cd $PROJECT_BASE/$DOWNLOAD_DIR && rm -rf opentelemetry-collector-contrib)