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 <noreply@anthropic.com> * 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 <noreply@anthropic.com> * 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 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
234bfd17f8
commit
549e0c6035
1 changed files with 18 additions and 3 deletions
21
Taskfile.yml
21
Taskfile.yml
|
|
@ -3,20 +3,35 @@ version: '3'
|
||||||
vars:
|
vars:
|
||||||
VERSION:
|
VERSION:
|
||||||
sh: git describe --tags --exact-match 2>/dev/null || echo "dev"
|
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:
|
tasks:
|
||||||
# --- CLI Management ---
|
# --- CLI Management ---
|
||||||
cli:build:
|
cli:build:
|
||||||
desc: "Build core CLI to ./bin/core"
|
desc: "Build core CLI to ./bin/core (dev build with debug info)"
|
||||||
cmds:
|
cmds:
|
||||||
- go build -ldflags '{{.LDFLAGS}}' -o ./bin/core .
|
- 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:
|
cli:install:
|
||||||
desc: "Install core CLI to system PATH"
|
desc: "Install core CLI to system PATH (dev build)"
|
||||||
cmds:
|
cmds:
|
||||||
- go install -ldflags '{{.LDFLAGS}}' .
|
- go install -ldflags '{{.LDFLAGS}}' .
|
||||||
|
|
||||||
|
cli:install:release:
|
||||||
|
desc: "Install core CLI for release (smaller binary)"
|
||||||
|
cmds:
|
||||||
|
- go install -ldflags '{{.LDFLAGS_RELEASE}}' .
|
||||||
|
|
||||||
# --- Development ---
|
# --- Development ---
|
||||||
test:
|
test:
|
||||||
desc: "Run all tests"
|
desc: "Run all tests"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue