diff --git a/Dockerfile b/Dockerfile index 0145678..fddd49f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..9bcf1cf --- /dev/null +++ b/build.sh @@ -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