Pudong b2592b14cc
[image-build] refactor image build (#19474)
* add experimental config for set baseImageRepo and workspaceImageRepo

* use crane speed up build workpace image layer

* refactor image build logic

* Indicate when BuildStarted fails

* Revert "Indicate when BuildStarted fails"

This reverts commit 11f36f1b76164a3777d27430dd35aacb322fe2f4.

* Apply suggestions from code review

Co-authored-by: Kyle Brennan <kyle@gitpod.io>

* update readme

* remove warn

---------

Co-authored-by: Kyle Brennan <kyle@gitpod.io>
2024-03-28 13:54:37 +01:00

35 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Copyright (c) 2024 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License.AGPL.txt in the project root for license information.
set -Eeuo pipefail
# Login in GCloud to reuse remote caches
ROOT_DIR="$(dirname "$0")/../.."
source "$ROOT_DIR/dev/preview/workflow/lib/ensure-gcloud-auth.sh"
ensure_gcloud_auth
# This script builds the image-builder-bob, patches the image-builder-mk3 configmap to use the new bob, and restarts image-builder-mk3
version="dev-$(date +%F_T"%H-%M-%S")"
echo "Image Version: $version"
bldfn="/tmp/build-$version.tar.gz"
docker ps &> /dev/null || (echo "You need a working Docker daemon. Maybe set DOCKER_HOST?"; exit 1)
leeway build -Dversion="$version" -DimageRepoBase=eu.gcr.io/gitpod-core-dev/build .:docker --save "$bldfn"
dev_image="$(tar xfO "$bldfn" ./imgnames.txt | head -n1)"
echo "Dev Image: $dev_image"
cf_patch=$(kubectl get cm image-builder-mk3-config -o=json | jq '.data."image-builder.json"' |jq -r)
cf_patch=$(echo "$cf_patch" |jq ".orchestrator.builderImage = \"$dev_image\"")
cf_patch=$(echo "$cf_patch" |jq tostring)
cf_patch="{\"data\": {\"image-builder.json\": $cf_patch}}"
kubectl patch cm image-builder-mk3-config --type=merge -p "$cf_patch"
kubectl rollout restart deployment image-builder-mk3