From b822b73a03fd4429a11512c9e7af216ca1db1ab3 Mon Sep 17 00:00:00 2001
From: Aveline <352441+ym@users.noreply.github.com>
Date: Thu, 12 Jun 2025 14:04:51 +0200
Subject: [PATCH] chore: use pure Go resolver and remove CGO_ENABLED=0 (#603)

---
 Makefile      | 9 ++++++---
 dev_deploy.sh | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 5f57fb3..16994a4 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,8 @@ VERSION := 0.4.3
 PROMETHEUS_TAG := github.com/prometheus/common/version
 KVM_PKG_NAME := github.com/jetkvm/kvm
 
+GO_BUILD_ARGS := -tags netgo
+GO_RELEASE_BUILD_ARGS := -trimpath $(GO_BUILD_ARGS)
 GO_LDFLAGS := \
   -s -w \
   -X $(PROMETHEUS_TAG).Branch=$(BRANCH) \
@@ -15,7 +17,7 @@ GO_LDFLAGS := \
   -X $(PROMETHEUS_TAG).Revision=$(REVISION) \
   -X $(KVM_PKG_NAME).builtTimestamp=$(BUILDTS)
 
-GO_CMD := GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=0 go
+GO_CMD := GOOS=linux GOARCH=arm GOARM=7 go
 BIN_DIR := $(shell pwd)/bin
 
 TEST_DIRS := $(shell find . -name "*_test.go" -type f -exec dirname {} \; | sort -u)
@@ -27,7 +29,7 @@ build_dev: hash_resource
 	@echo "Building..."
 	$(GO_CMD) build \
 		-ldflags="$(GO_LDFLAGS) -X $(KVM_PKG_NAME).builtAppVersion=$(VERSION_DEV)" \
-		-trimpath \
+		$(GO_RELEASE_BUILD_ARGS) \
 		-o $(BIN_DIR)/jetkvm_app cmd/main.go
 
 build_test2json:
@@ -50,6 +52,7 @@ build_dev_test: build_test2json build_gotestsum
 		test_filename=$$(echo $$test_pkg_name | sed 's/\//__/g')_test; \
 		$(GO_CMD) test -v \
 			-ldflags="$(GO_LDFLAGS) -X $(KVM_PKG_NAME).builtAppVersion=$(VERSION_DEV)" \
+			$(GO_BUILD_ARGS) \
 			-c -o $(BIN_DIR)/tests/$$test_filename $$test; \
 		echo "runTest ./$$test_filename $$test_pkg_full_name" >> $(BIN_DIR)/tests/run_all_tests; \
 	done; \
@@ -71,7 +74,7 @@ build_release: frontend hash_resource
 	@echo "Building release..."
 	$(GO_CMD) build \
 		-ldflags="$(GO_LDFLAGS) -X $(KVM_PKG_NAME).builtAppVersion=$(VERSION)" \
-		-trimpath \
+		$(GO_RELEASE_BUILD_ARGS) \
 		-o bin/jetkvm_app cmd/main.go
 
 release:
diff --git a/dev_deploy.sh b/dev_deploy.sh
index a2d32ed..059e416 100755
--- a/dev_deploy.sh
+++ b/dev_deploy.sh
@@ -174,7 +174,7 @@ cd "${REMOTE_PATH}"
 chmod +x jetkvm_app_debug
 
 # Run the application in the background
-PION_LOG_TRACE=${LOG_TRACE_SCOPES} ./jetkvm_app_debug
+PION_LOG_TRACE=${LOG_TRACE_SCOPES} GODEBUG=netdns=1 ./jetkvm_app_debug
 EOF
 
 echo "Deployment complete."
\ No newline at end of file