hsa-app/scripts/build.sh
Jean-Michel Tremblay 99b8541da0 Static portable build + env-file launcher for deployment
- build.sh: CGO_ENABLED=0 + -ldflags "-s -w" → fully static binary (pure-Go
  SQLite, no C toolchain), runs on any linux/<arch>; note GOARCH cross-compile.
- scripts/hsa-app.sh: load an env file (default /etc/hsa-app/hsa-app.env, or arg/
  $HSA_ENV_FILE), export it, then exec the binary ($HSA_BIN or ./hsa next to it).
  Suitable as a systemd ExecStart.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 08:32:19 -04:00

13 lines
573 B
Bash
Executable file

#!/usr/bin/env bash
# Build the hsa binary into the repo root.
#
# CGO_ENABLED=0 makes a fully static binary (the SQLite driver is pure Go, so no
# C toolchain is needed): it runs on any linux/<arch> — glibc or musl/Alpine,
# scratch containers, etc. — with no shared-library dependencies.
# Cross-compile for another arch by setting GOARCH, e.g.:
# GOARCH=arm64 ./scripts/build.sh
set -euo pipefail
cd "$(dirname "$0")/.."
source scripts/go-env.sh
CGO_ENABLED=0 go build -ldflags "-s -w" -o hsa ./cmd/hsa
echo "Built ./hsa ($(go env GOOS)/$(go env GOARCH), static)"