Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Build node with the version from VERSION injected at link time.
# scripts/build.sh [output-path]
# Build node — a fully static, single binary (no dynamic linking, ever):
# CGO_ENABLED=0 forces pure-Go net (netgo) + os/user (osusergo) too, so there
# is no libc dependency. Version is injected from VERSION at link time.
# scripts/build.sh [output-path] (GOOS/GOARCH from env for cross-builds)
set -euo pipefail
cd "$(dirname "$0")/.."
VERSION="$(tr -d '[:space:]' < VERSION)"
go build -ldflags "-X github.com/PharosVPN/node/internal/cli.version=$VERSION" -o "${1:-bin/node}" ./cmd/node
echo "built node $VERSION -> ${1:-bin/node}"
CGO_ENABLED=0 go build -trimpath -tags netgo,osusergo \
-ldflags "-X github.com/PharosVPN/node/internal/cli.version=$VERSION" \
-o "${1:-bin/node}" ./cmd/node
echo "built node $VERSION (static) -> ${1:-bin/node}"
Loading