build(ws-server): -trimpath -ldflags="-s -w" (RFC#563) #1570
Reference in New Issue
Block a user
Delete Branch "feat/rfc563-ws-server-binary-strip"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add
-trimpath -ldflags="-s -w"to thego buildinvocations inworkspace-server/Dockerfileandworkspace-server/Dockerfile.tenant,mirroring the pattern already in
molecule-controlplane/Dockerfile.Implements the workspace-server piece of RFC molecule-ai/internal#563.
Empirical measurement
Local build,
CGO_ENABLED=0 GOOS=linux GOARCH=amd64, go 1.26.3,/platformbinary only (host:core-be, mac):RFC#563 reports the published image deltas as 87 -> 61 MB (-26 MB, ~29%) —
the per-image figure is larger than per-binary because both
/platformand
/memory-pluginare stripped, plus the binary is just one layerof a multi-layer image.
Flag semantics
-trimpath— strip absolute build-host paths from object code (alsoimproves reproducibility)
-ldflags "-s -w"— linker drops the symbol table (-s) and DWARFdebug info (
-w)-X .../buildinfo.GitSHA=${GIT_SHA}is preserved inside the same-ldflagsstring;-X-injected strings live in static data, not thesymbol table, so they survive
-s. Verified locally:Scope
Single-purpose: only
workspace-server/Dockerfile+workspace-server/Dockerfile.tenanttouched. No behavioural changeto the binaries; no other build args, base images, or CI workflow
changes in this PR.
Test plan
/platform -version(or call/buildinfo) and confirmGitSHAstill reports the workflow's${{ github.sha }}— i.e. stripping did not erase the-X-injected build vardocker image inspectsizes pre/post to confirm theRFC#563 ~26MB delta on the final image (not just the binary)
Notes
matches CP-side Dockerfile (it does) and that
-Xsemantics under-s -ware correctly understood (they are — see Go linker docs).Mirror the pattern already used in molecule-controlplane/Dockerfile. Currently workspace-server only sets -X buildinfo.GitSHA; add -trimpath plus -s -w (strip symbol table + DWARF debug info) inside the same -ldflags string. The -X GitSHA injection is preserved (verified via strings(1) on locally-built binary). Empirical local measurement (CGO_ENABLED=0 GOOS=linux GOARCH=amd64, go 1.26.3, /platform binary only): before 44,669,544 bytes (42 MB) after 31,191,202 bytes (29 MB) delta 13,478,342 bytes (12 MB) — 30.2% reduction RFC#563 reports the published *image* deltas as 87 -> 61 MB (-26 MB, ~29%); the per-image figure is larger than the per-binary figure because both /platform and /memory-plugin are stripped, and the binary is one layer of the multi-layer image. Flag semantics (Go 1.26): -trimpath strip absolute build-host paths from object code (also improves reproducibility) -ldflags "-s -w" linker drops symbol table (-s) and DWARF debug info (-w); -X-injected strings are NOT in the symbol table so GitSHA survives stripping Single-purpose change: only ws-server Dockerfile + Dockerfile.tenant touched; no behavioral changes to the binaries themselves.mc#1570 RFC#563 ws-server -trimpath/-s/-w. Pattern mirrors molecule-controlplane/Dockerfile. Diff Dockerfile-only; -X-injected GitSHA preserved (per RFC and verified locally by author). No behavioral change. QA APPROVE.
mc#1570 RFC#563 ws-server binary strip (-trimpath, -s, -w). Build-time only, no behavioral change. Strips debug symbols + build-host paths (privacy improvement). GitSHA via -X preserved. Security APPROVE.