build: add Linux web and backend bundle script

This commit is contained in:
2026-07-24 15:08:06 +08:00
parent f430566976
commit 127dc04795
2 changed files with 29 additions and 0 deletions

28
scripts/build-web-linux.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
BUILD_DIR="$ROOT_DIR/.builds/linux"
BACKEND_DIR="$BUILD_DIR/backend"
WEB_DIR="$BUILD_DIR/web_v1"
# Override GOARCH when building for another Linux architecture, for example arm64.
GOARCH="${GOARCH:-amd64}"
rm -rf "$BACKEND_DIR" "$WEB_DIR"
mkdir -p "$BACKEND_DIR" "$WEB_DIR"
(
cd "$ROOT_DIR/backend"
go test ./...
CGO_ENABLED=0 GOOS=linux GOARCH="$GOARCH" go build -trimpath -o "$BACKEND_DIR/senlin-agent-api" ./cmd/api
)
(
cd "$ROOT_DIR/apps/web_v1"
npm run build
cp -R dist/. "$WEB_DIR/"
)
echo "Linux backend: $BACKEND_DIR/senlin-agent-api"
echo "Web build: $WEB_DIR"