2022-05-11 22:47:31 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
set -e
|
2023-03-08 06:12:57 +00:00
|
|
|
|
set +x
|
2022-05-11 22:47:31 +00:00
|
|
|
|
|
|
|
|
|
IMAGE=jc21/gotools:latest
|
|
|
|
|
|
|
|
|
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
. "$DIR/../.common.sh"
|
|
|
|
|
|
|
|
|
|
BUILD_DATE=$(date '+%Y-%m-%d %T %Z')
|
|
|
|
|
NOW=$(date --rfc-3339=s)
|
|
|
|
|
|
|
|
|
|
cd $DIR/../..
|
|
|
|
|
|
|
|
|
|
if [ "$BUILD_COMMIT" = "" ]; then
|
|
|
|
|
BUILD_COMMIT=$(git log -n 1 --format=%h)
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$BUILD_VERSION" = "" ]; then
|
|
|
|
|
BUILD_VERSION=$(cat .version)
|
|
|
|
|
fi
|
|
|
|
|
|
2023-05-27 02:43:07 +00:00
|
|
|
|
export CGO_ENABLED=0
|
2023-02-25 14:14:35 +00:00
|
|
|
|
export GO111MODULE=on
|
|
|
|
|
|
2022-05-11 22:47:31 +00:00
|
|
|
|
echo -e "${BLUE}❯ ${GREEN}build-backend:${RESET}"
|
|
|
|
|
echo " BUILD_COMMIT: $BUILD_COMMIT"
|
|
|
|
|
echo " BUILD_DATE: $BUILD_DATE"
|
|
|
|
|
echo " BUILD_VERSION: $BUILD_VERSION"
|
|
|
|
|
echo " CGO_ENABLED: ${CGO_ENABLED:-}"
|
|
|
|
|
echo " GO111MODULE: ${GO111MODULE:-}"
|
|
|
|
|
echo " GOPRIVATE: ${GOPRIVATE:-}"
|
|
|
|
|
echo " GOPROXY: ${GOPROXY:-}"
|
|
|
|
|
echo " NOW: $NOW"
|
|
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
|
docker run --rm -v "$(pwd):/app" "${IMAGE}" chown -R "$(id -u):$(id -g)" /app/bin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
build_backend() {
|
|
|
|
|
echo -e "${BLUE}❯ ${CYAN}Building backend for ${YELLOW}${1}-${2} ...${RESET}"
|
|
|
|
|
|
|
|
|
|
FILENAME="nginxproxymanager-${1}_${2}"
|
|
|
|
|
if [ "$1" = "windows" ]; then
|
|
|
|
|
FILENAME="${FILENAME}.exe"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
docker run --rm \
|
|
|
|
|
-e BUILD_COMMIT="${BUILD_COMMIT:-notset}" \
|
|
|
|
|
-e BUILD_DATE="$BUILD_DATE" \
|
|
|
|
|
-e GOARCH="${2}" \
|
|
|
|
|
-e GOOS="${1}" \
|
|
|
|
|
-e GOPRIVATE="${GOPRIVATE:-}" \
|
|
|
|
|
-e GOPROXY="${GOPROXY:-}" \
|
|
|
|
|
-e NOW="$NOW" \
|
|
|
|
|
-e TZ="${TZ:-Australia/Brisbane}" \
|
|
|
|
|
-v "$(pwd):/app" \
|
|
|
|
|
-w '/app/backend' \
|
|
|
|
|
"${IMAGE}" \
|
|
|
|
|
go build \
|
2023-05-26 01:04:43 +00:00
|
|
|
|
-tags 'json1' \
|
2023-02-24 11:21:14 +00:00
|
|
|
|
-buildvcs=false \
|
2022-05-11 22:47:31 +00:00
|
|
|
|
-ldflags "-w -s -X main.commit=${BUILD_COMMIT:-notset} -X main.version=${BUILD_VERSION} -X main.sentryDSN=${SENTRY_DSN:-}" \
|
|
|
|
|
-o "/app/bin/$FILENAME" \
|
|
|
|
|
./cmd/server
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
docker pull "${IMAGE}"
|
|
|
|
|
|
2023-05-26 11:53:24 +00:00
|
|
|
|
#build_backend "darwin" "amd64"
|
|
|
|
|
#build_backend "darwin" "arm64"
|
2022-05-11 22:47:31 +00:00
|
|
|
|
build_backend "linux" "amd64"
|
2023-05-27 02:43:07 +00:00
|
|
|
|
#build_backend "linux" "arm64"
|
2022-05-11 22:47:31 +00:00
|
|
|
|
build_backend "linux" "arm"
|
2023-05-26 11:53:24 +00:00
|
|
|
|
#build_backend "openbsd" "amd64"
|
|
|
|
|
#build_backend "windows" "amd64"
|
2022-05-11 22:47:31 +00:00
|
|
|
|
|
|
|
|
|
cleanup
|
|
|
|
|
|
|
|
|
|
echo -e "${BLUE}❯ ${GREEN}build-backend completed${RESET}"
|
|
|
|
|
exit 0
|