Statically link libc (musl) so the binaries are fully portable
This commit is contained in:
parent
8c9fb06e52
commit
fc08fb0be4
@ -1,6 +1,6 @@
|
|||||||
from ubuntu:jammy
|
from ubuntu:jammy
|
||||||
|
|
||||||
run apt update && apt install -y sudo curl wget build-essential sqlite3 jq git
|
run apt update && apt install -y sudo curl wget build-essential sqlite3 jq git musl-dev musl-tools
|
||||||
|
|
||||||
# Install go and golangci-lint
|
# Install go and golangci-lint
|
||||||
run wget https://go.dev/dl/go1.20.4.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.20.4.linux-amd64.tar.gz
|
run wget https://go.dev/dl/go1.20.4.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.20.4.linux-amd64.tar.gz
|
||||||
|
@ -3,9 +3,14 @@
|
|||||||
set -x
|
set -x
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
export CGO_ENABLED=1
|
||||||
|
export CC=musl-gcc
|
||||||
|
|
||||||
|
FLAGS="-s -w -linkmode=external -extldflags=-static -X gitlab.com/offline-twitter/twitter_offline_engine/internal/webserver.use_embedded=true"
|
||||||
|
|
||||||
if [[ -n "$1" ]]; then
|
if [[ -n "$1" ]]; then
|
||||||
go build -ldflags="-s -w -X main.version_string=$1 -X gitlab.com/offline-twitter/twitter_offline_engine/internal/webserver.use_embedded=true" -o tw ./twitter
|
go build -ldflags="$FLAGS -X main.version_string=$1" -o tw ./twitter
|
||||||
else
|
else
|
||||||
go build -ldflags="-s -w -X gitlab.com/offline-twitter/twitter_offline_engine/internal/webserver.use_embedded=true" -o tw ./twitter
|
go build -ldflags="$FLAGS" -o tw ./twitter
|
||||||
fi
|
fi
|
||||||
chmod +x tw
|
chmod +x tw
|
||||||
|
@ -13,4 +13,4 @@ if [[ -z "$1" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
go build -ldflags="-linkmode external -extldflags -static -s -w -X main.version_string=$1 -X gitlab.com/offline-twitter/twitter_offline_engine/internal/webserver.use_embedded=true" -buildvcs=false -o twitter.exe ./twitter
|
go build -ldflags="-linkmode external -extldflags -static -s -w -X main.version_string=$1 -X gitlab.com/offline-twitter/twitter_offline_engine/internal/webserver.use_embedded=true" -o twitter.exe ./twitter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user