2023-05-02 03:13:37 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
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-05-03 05:13:28 +00:00
|
|
|
BUILDNUMBER="N/A"
|
|
|
|
CONTAINER_IMAGE_TAG="N/A"
|
|
|
|
NODE_VERSION="0"
|
|
|
|
YARN_VERSION="0"
|
|
|
|
WEBPACK_VERSION="0"
|
|
|
|
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"
|
|
|
|
|
2023-05-02 03:13:37 +00:00
|
|
|
|
|
|
|
cd api || exit 1
|
2021-10-28 11:18:13 +00:00
|
|
|
# the go get adds 8 seconds
|
2019-01-30 22:37:16 +00:00
|
|
|
go get -t -d -v ./...
|
|
|
|
|
2023-05-03 05:13:28 +00:00
|
|
|
|
|
|
|
ldflags="-s -X 'github.com/portainer/liblicense.LicenseServerBaseURL=https://api.portainer.io' \
|
|
|
|
-X 'github.com/portainer/portainer-ee/api/build.BuildNumber=${BUILDNUMBER}' \
|
|
|
|
-X 'github.com/portainer/portainer-ee/api/build.ImageTag=${CONTAINER_IMAGE_TAG}' \
|
|
|
|
-X 'github.com/portainer/portainer-ee/api/build.NodejsVersion=${NODE_VERSION}' \
|
|
|
|
-X 'github.com/portainer/portainer-ee/api/build.YarnVersion=${YARN_VERSION}' \
|
|
|
|
-X 'github.com/portainer/portainer-ee/api/build.WebpackVersion=${WEBPACK_VERSION}' \
|
|
|
|
-X 'github.com/portainer/portainer-ee/api/build.GoVersion=${GO_VERSION}'"
|
|
|
|
|
|
|
|
BINARY_VERSION_FILE="../binary-version.json"
|
|
|
|
|
|
|
|
echo "$ldflags"
|
|
|
|
|
2021-10-28 11:18:13 +00:00
|
|
|
# the build takes 2 seconds
|
2023-05-03 05:13:28 +00:00
|
|
|
GOOS=${1:-$(go env GOOS)} GOARCH=${2:-$(go env GOARCH)} CGO_ENABLED=0 go build \
|
2022-10-11 16:00:50 +00:00
|
|
|
-trimpath \
|
2021-10-28 11:18:13 +00:00
|
|
|
--installsuffix cgo \
|
2023-05-03 05:13:28 +00:00
|
|
|
--ldflags "$ldflags" \
|
|
|
|
-o "../dist/portainer" \
|
|
|
|
./cmd/portainer/
|