dockerimg: Add race detector support to sketch binary build
Run this with:
go run -race ./cmd/sketch -C $(pwd) -verbose -termui=false
-race requires CGO which makes cross compilation miserable, so, we punt,
and we use the container to do it.
The big TODO is that there's no go caching, so it's kinda slower than it
needs to be. This is probably fixable with a docker volume.
When the host binary is built with the race detector enabled (-race flag),
the inner sketch binary that runs in Docker will also be built with the race
detector. This helps with debugging race conditions in the inner binary.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s822ae1a915dcc857k
diff --git a/dockerimg/racedetector.go b/dockerimg/racedetector.go
new file mode 100644
index 0000000..6bcb754
--- /dev/null
+++ b/dockerimg/racedetector.go
@@ -0,0 +1,10 @@
+//go:build !race
+
+// Package dockerimg provides functionality for creating and managing Docker images.
+package dockerimg
+
+// RaceEnabled returns whether the race detector is enabled.
+// This function will always return false when compiled without the race detector.
+func RaceEnabled() bool {
+ return false
+}