#!/bin/sh # script/build: compile the static netwatch-server binary into the # backend project root, with its version and architecture stamped in. set -eu ROOT="$(cd "$(dirname "$0")/.." && pwd -P)" main() { cd "$ROOT" # VERSION comes from the environment (Dockerfile.backend passes its # ARG VERSION in). Unset or empty, it is git describe, or "dev" where # there is no git or no repository history. version="${VERSION:-$(git describe --always --dirty 2>/dev/null || echo dev)}" CGO_ENABLED=0 go build -trimpath \ -ldflags "-s -w -X main.Version=$version -X main.Buildarch=$(uname -m)" \ -o netwatch-server ./cmd/netwatch-server/ } main "$@"