ooni-probe-cli/CLI/go-build-alpine
Simone Basso 0d57899f46
feat: stop cross compiling miniooni (#908)
See https://github.com/ooni/probe/issues/2119

While there, shrink the Makefile to only export the minimum
set of rules to comfortable build using GHA.
2022-08-30 11:36:59 +02:00

21 lines
646 B
Bash
Executable File

#!/bin/sh
set -euxo pipefail
apk update
apk upgrade
apk add --no-progress gcc git linux-headers musl-dev
# We need to force git to look into this repository owned by the
# user outside docker rather than by the user running docker
git config --global --add safe.directory $(pwd)
# Some of the following exports are redundant but are however
# useful because they provide explicit logging
export CGO_ENABLED=1
export GOARM=$GOARM
export GOOS=$GOOS
export GOARCH=$GOARCH
for PACKAGE in $@; do
PRODUCT=$(basename $PACKAGE)
go build -o ./CLI/$PRODUCT-$GOOS-$OONIARCH \
-ldflags='-s -w -extldflags "-static"' \
$GOLANG_EXTRA_FLAGS $PACKAGE
done