2022-09-20 21:48:07 +00:00
|
|
|
#!/bin/sh
|
2023-03-08 02:34:55 +00:00
|
|
|
DEBUG=${DEBUG:-""}
|
|
|
|
if [ -n "$DEBUG" ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
2019-01-30 22:37:16 +00:00
|
|
|
|
2021-10-28 11:18:13 +00:00
|
|
|
mkdir -p dist
|
2019-01-30 22:37:16 +00:00
|
|
|
|
2022-07-14 23:09:38 +00:00
|
|
|
# populate tool versions
|
2023-03-08 02:34:55 +00:00
|
|
|
BUILD_NUMBER=${BUILD_NUMBER:-"N/A"}
|
|
|
|
CONTAINER_IMAGE_TAG=${CONTAINER_IMAGE_TAG:-"N/A"}
|
|
|
|
NODE_VERSION=${NODE_VERSION:-"0"}
|
|
|
|
YARN_VERSION=${YARN_VERSION:-"0"}
|
|
|
|
WEBPACK_VERSION=${WEBPACK_VERSION:-"0"}
|
|
|
|
GO_VERSION=${GO_VERSION:-"0"}
|
2022-07-14 23:09:38 +00:00
|
|
|
|
2022-12-11 06:58:22 +00:00
|
|
|
# copy templates
|
|
|
|
cp -r "./mustache-templates" "./dist"
|
|
|
|
|
2021-10-28 11:18:13 +00:00
|
|
|
cd api
|
|
|
|
# the go get adds 8 seconds
|
2019-01-30 22:37:16 +00:00
|
|
|
go get -t -d -v ./...
|
|
|
|
|
2021-10-28 11:18:13 +00:00
|
|
|
# the build takes 2 seconds
|
|
|
|
GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build \
|
2022-10-11 16:00:50 +00:00
|
|
|
-trimpath \
|
2021-10-28 11:18:13 +00:00
|
|
|
--installsuffix cgo \
|
2022-07-14 23:09:38 +00:00
|
|
|
--ldflags "-s \
|
2023-03-08 02:34:55 +00:00
|
|
|
--X 'github.com/portainer/portainer/api/build.BuildNumber=${BUILD_NUMBER}' \
|
2022-09-20 21:48:07 +00:00
|
|
|
--X 'github.com/portainer/portainer/api/build.ImageTag=${CONTAINER_IMAGE_TAG}' \
|
|
|
|
--X 'github.com/portainer/portainer/api/build.NodejsVersion=${NODE_VERSION}' \
|
|
|
|
--X 'github.com/portainer/portainer/api/build.YarnVersion=${YARN_VERSION}' \
|
|
|
|
--X 'github.com/portainer/portainer/api/build.WebpackVersion=${WEBPACK_VERSION}' \
|
|
|
|
--X 'github.com/portainer/portainer/api/build.GoVersion=${GO_VERSION}'" \
|
2021-10-28 11:18:13 +00:00
|
|
|
-o "../dist/portainer" \
|
|
|
|
./cmd/portainer/
|