From 2c8e92134bafe2544e4787551d7c2a9b60f65d6f Mon Sep 17 00:00:00 2001 From: hessjc Date: Thu, 5 Feb 2026 04:18:39 +0000 Subject: [PATCH] chore: Add new build.sh build_image command to build. This will build and optionaly push the container image --- build.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/build.sh b/build.sh index 3d907c3eb..9d8f83ce8 100755 --- a/build.sh +++ b/build.sh @@ -231,6 +231,48 @@ function write_e2e_env(){ } +## build_image - Builds and pushes the proxy container image using local source. +## Usage: ./build.sh build_image [image-url] +function build_image() { + local image_url="${1:-}" + local push_arg="" + + if [[ -n "$image_url" ]]; then + push_arg="--push" + echo "Preparing to build and push proxy image: $image_url" + else + echo "Preparing to build proxy image (no push)..." + push_arg="--load" + image_url="cloud-sql-proxy:local" + fi + + function cleanup_build() { + rm -f cloud-sql-proxy Dockerfile.local + } + trap cleanup_build EXIT + + echo "Building binary locally..." + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X github.com/GoogleCloudPlatform/cloud-sql-proxy/v2/cmd.metadataString=container" -o cloud-sql-proxy + + echo "Creating temporary Dockerfile..." + cat > Dockerfile.local <