This commit is contained in:
darmiel 2021-05-17 18:12:51 +02:00
parent 1eff5a1158
commit 448b801f5e
2 changed files with 43 additions and 1 deletions

View file

@ -15,7 +15,7 @@ RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
COPY . .
# Build from sources
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o yaxc .
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -flags client,server -o yaxc .
# Output Image
FROM alpine

42
build.sh Normal file
View file

@ -0,0 +1,42 @@
#!/bin/bash
# clear old builds
rm bin/*
NAME="server-only"
TAGS="server"
# ignored platforms
IGNORED=("aix" "android" "ios" "plan9" "js")
# get possible build configurations
POSSIBLE=$(go tool dist list)
for poss in $POSSIBLE; do
IFS="/"
read -r -a poss_array <<< "$poss"
PLATFORM="${poss_array[0]}"
ARCH="${poss_array[1]}"
if [[ " ${IGNORED[@]} " =~ " ${PLATFORM} " ]]; then
continue
fi
OUTF="./bin/yaxc-${NAME}-${PLATFORM}-${ARCH}"
if [[ "${PLATFORM}" == "windows" ]]; then
OUTF="${OUTF}.exe"
fi
echo ""
echo "🔨 Building for ${PLATFORM}(${ARCH}) ..."
echo " 👉 ${OUTF}"
# build
GOOS=${PLATFORM} GOARCH=${ARCH} go build \
-ldflags="-s -w" \
-o "${OUTF}" \
./main.go
echo " Done!"
done