1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 05:19:39 +02:00

build: introduce central Makefile and live-reload for Go (#184)

This commit is contained in:
Anthony Lapenna 2024-12-03 08:49:03 +13:00 committed by GitHub
parent a261f60764
commit bb6815f681
6 changed files with 113 additions and 16 deletions

View file

@ -32,8 +32,14 @@ cp -r "./mustache-templates" "./dist"
cd api || exit 1
# the go get adds 8 seconds
go get -t -d -v ./...
# Conditionally run go get based on the SKIP_GO_GET environment variable
# This process adds a bit of time to the build
# This is useful in the CI/CD pipeline to ensure that all dependencies are available
if [ "${SKIP_GO_GET:-false}" = false ]; then
echo "Running go get -t -v ./..."
go get -t -v ./...
fi
ldflags="-s -X 'github.com/portainer/liblicense.LicenseServerBaseURL=https://api.portainer.io' \
@ -51,7 +57,6 @@ ldflags="-s -X 'github.com/portainer/liblicense.LicenseServerBaseURL=https://api
echo "$ldflags"
# the build takes 2 seconds
GOOS=${1:-$(go env GOOS)} GOARCH=${2:-$(go env GOARCH)} CGO_ENABLED=0 go build \
-trimpath \
--installsuffix cgo \

View file

@ -1,7 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
PLATFORM=${1:-"linux"}
ARCH=${2:-"amd64"}
@ -14,10 +13,49 @@ mingitVersion=$(jq -r '.mingit' < "${BINARY_VERSION_FILE}")
mkdir -p dist
echo "Downloading binaries for docker ${dockerVersion}, helm ${helmVersion}, kubectl ${kubectlVersion} and mingit ${mingitVersion}"
echo "Checking and downloading binaries for docker ${dockerVersion}, helm ${helmVersion}, kubectl ${kubectlVersion} and mingit ${mingitVersion} (Windows only)"
./build/download_docker_binary.sh "$PLATFORM" "$ARCH" "$dockerVersion" &
./build/download_helm_binary.sh "$PLATFORM" "$ARCH" "$helmVersion" &
./build/download_kubectl_binary.sh "$PLATFORM" "$ARCH" "$kubectlVersion" &
./build/download_mingit_binary.sh "$PLATFORM" "$ARCH" "$mingitVersion" &
wait
# Determine the binary file names based on the platform
dockerBinary="dist/docker"
helmBinary="dist/helm"
kubectlBinary="dist/kubectl"
if [ "$PLATFORM" == "windows" ]; then
dockerBinary="dist/docker.exe"
helmBinary="dist/helm.exe"
kubectlBinary="dist/kubectl.exe"
fi
# Check and download docker binary
if [ ! -f "$dockerBinary" ]; then
echo "Downloading docker binary..."
/usr/bin/env bash ./build/download_docker_binary.sh "$PLATFORM" "$ARCH" "$dockerVersion"
else
echo "Docker binary already exists, skipping download."
fi
# Check and download helm binary
if [ ! -f "$helmBinary" ]; then
echo "Downloading helm binary..."
/usr/bin/env bash ./build/download_helm_binary.sh "$PLATFORM" "$ARCH" "$helmVersion"
else
echo "Helm binary already exists, skipping download."
fi
# Check and download kubectl binary
if [ ! -f "$kubectlBinary" ]; then
echo "Downloading kubectl binary..."
/usr/bin/env bash ./build/download_kubectl_binary.sh "$PLATFORM" "$ARCH" "$kubectlVersion"
else
echo "Kubectl binary already exists, skipping download."
fi
# Check and download mingit binary only for Windows
if [ "$PLATFORM" == "windows" ]; then
if [ ! -f "dist/mingit" ]; then
echo "Downloading mingit binary..."
/usr/bin/env bash ./build/download_mingit_binary.sh "$PLATFORM" "$ARCH" "$mingitVersion"
else
echo "Mingit binary already exists, skipping download."
fi
fi