From 549e0c6035c1a3ae501792635e1d257059e61c7e Mon Sep 17 00:00:00 2001 From: Snider Date: Mon, 2 Feb 2026 04:22:00 +0000 Subject: [PATCH] build: add release build tasks with linker flags (#239) * fix(container): prevent data race in State.Get and State.All Return copies of Container structs instead of pointers to the map entries. This prevents data races when containers are modified concurrently by waitForExit and Stop. Fixes #76 Co-Authored-By: Claude Opus 4.5 * fix(updater): resolve PkgVersion duplicate declaration Remove var PkgVersion from updater.go since go generate creates const PkgVersion in version.go. Track version.go in git to ensure builds work without running go generate first. Co-Authored-By: Claude Opus 4.5 * build: add release build tasks with linker flags for smaller binary Add -s -w linker flags to strip debug info and symbol table: - cli:build:release - release build to ./bin/core - cli:install:release - release install to system PATH Binary size reduced from 19MB to 14MB (26% reduction). Fixes #226 Co-Authored-By: Claude Opus 4.5 --------- Co-authored-by: Claude Opus 4.5 --- Taskfile.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index de548953..d4379901 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -3,20 +3,35 @@ version: '3' vars: VERSION: sh: git describe --tags --exact-match 2>/dev/null || echo "dev" - LDFLAGS: "-X github.com/host-uk/core/pkg/cli.AppVersion={{.VERSION}}" + # Base ldflags for version injection + LDFLAGS_BASE: "-X github.com/host-uk/core/pkg/cli.AppVersion={{.VERSION}}" + # Development build: includes debug info + LDFLAGS: "{{.LDFLAGS_BASE}}" + # Release build: strips debug info and symbol table for smaller binary + LDFLAGS_RELEASE: "-s -w {{.LDFLAGS_BASE}}" tasks: # --- CLI Management --- cli:build: - desc: "Build core CLI to ./bin/core" + desc: "Build core CLI to ./bin/core (dev build with debug info)" cmds: - go build -ldflags '{{.LDFLAGS}}' -o ./bin/core . + cli:build:release: + desc: "Build core CLI for release (smaller binary, no debug info)" + cmds: + - go build -ldflags '{{.LDFLAGS_RELEASE}}' -o ./bin/core . + cli:install: - desc: "Install core CLI to system PATH" + desc: "Install core CLI to system PATH (dev build)" cmds: - go install -ldflags '{{.LDFLAGS}}' . + cli:install:release: + desc: "Install core CLI for release (smaller binary)" + cmds: + - go install -ldflags '{{.LDFLAGS_RELEASE}}' . + # --- Development --- test: desc: "Run all tests"