diff --git a/Makefile b/Makefile index ebcd21a3..fee845e4 100644 --- a/Makefile +++ b/Makefile @@ -84,6 +84,8 @@ help: @echo " All targets operate on KIND_NAMESPACE (default: hypershell-system)." @echo "" @echo " kind-up Create cluster + deploy all components (OIDC enabled)" + @echo " LOCAL_IMAGES=true: build from working tree (default)" + @echo " LOCAL_IMAGES=true BUILD_SOURCE=baseline: build from origin/main" @echo " kind-down Remove namespace and its resources" @echo " kind-teardown Destroy Kind cluster, stop cloud-provider-kind" @echo " kind-status Show cluster info, pods, services, swap state" @@ -282,7 +284,7 @@ test-all: install-js # ============================================================================ export CONTAINER_ENGINE KIND_CLUSTER_NAME KIND_NAMESPACE -export KIND_HOT_RELOAD KIND_HOST_MOUNT_PATH KIND_KEYCLOAK_URL LOCAL_IMAGES +export KIND_HOT_RELOAD KIND_HOST_MOUNT_PATH KIND_KEYCLOAK_URL LOCAL_IMAGES BUILD_SOURCE export KIND_PULL_SECRET KIND_DB_IMAGE export GATEWAY_API_VERSION KIND_VERSION CLOUD_PROVIDER_KIND_REPO CLOUD_PROVIDER_KIND_REF CLOUD_PROVIDER_KIND_BRANCH CERT_MANAGER_VERSION AGENT_SANDBOX_VERSION export IMAGE_REGISTRY IMAGE_TAG KIND_CONFIG diff --git a/scripts/kind/build-images.sh b/scripts/kind/build-images.sh index 6486035c..37e75416 100755 --- a/scripts/kind/build-images.sh +++ b/scripts/kind/build-images.sh @@ -5,7 +5,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=lib.sh source "${SCRIPT_DIR}/lib.sh" -header "Building Baseline Images from origin/main" +REPO_ROOT="$(git rev-parse --show-toplevel)" +BUILD_SOURCE="${BUILD_SOURCE:-worktree}" WORKTREE_DIR="" cleanup_worktree() { @@ -13,42 +14,50 @@ cleanup_worktree() { git worktree remove --force "${WORKTREE_DIR}" 2>/dev/null || rm -rf "${WORKTREE_DIR}" fi } -trap cleanup_worktree EXIT -info "Fetching origin/main..." -git fetch origin main --quiet - -WORKTREE_DIR=$(mktemp -d /tmp/hypershell-baseline-XXXXXX) -rm -rf "${WORKTREE_DIR}" -git worktree add --detach "${WORKTREE_DIR}" origin/main --quiet -info "Building from origin/main ($(git -C "${WORKTREE_DIR}" rev-parse --short HEAD))" +if [[ "${BUILD_SOURCE}" == "baseline" ]]; then + header "Building Baseline Images from origin/main" + trap cleanup_worktree EXIT + + info "Fetching origin/main..." + git fetch origin main --quiet + + WORKTREE_DIR=$(mktemp -d /tmp/hypershell-baseline-XXXXXX) + rm -rf "${WORKTREE_DIR}" + git worktree add --detach "${WORKTREE_DIR}" origin/main --quiet + BUILD_DIR="${WORKTREE_DIR}" + info "Building from origin/main ($(git -C "${WORKTREE_DIR}" rev-parse --short HEAD))" +else + header "Building Images from Working Tree" + BUILD_DIR="${REPO_ROOT}" + info "Building from working tree ($(git rev-parse --short HEAD))" +fi info "Building API server..." ${CONTAINER_ENGINE} build -t "${api_server_local}" \ - -f "${WORKTREE_DIR}/components/api-server/Dockerfile" \ + -f "${BUILD_DIR}/components/api-server/Dockerfile" \ --build-arg GIT_VERSION="${build_version}" \ --build-arg BUILD_TIME="${build_time}" \ - "${WORKTREE_DIR}/components/api-server" + "${BUILD_DIR}/components/api-server" info "Building control plane..." ${CONTAINER_ENGINE} build -t "${control_plane_local}" \ - -f "${WORKTREE_DIR}/components/control-plane/Dockerfile" "${WORKTREE_DIR}" + -f "${BUILD_DIR}/components/control-plane/Dockerfile" "${BUILD_DIR}" info "Building web console..." ${CONTAINER_ENGINE} build -t "${web_console_local}" \ - -f "${WORKTREE_DIR}/components/web-console/Dockerfile" "${WORKTREE_DIR}" + -f "${BUILD_DIR}/components/web-console/Dockerfile" "${BUILD_DIR}" success "All images built" -info "Tagging images with registry refs..." -${CONTAINER_ENGINE} tag "${api_server_local}" "${api_server_ref}" -${CONTAINER_ENGINE} tag "${control_plane_local}" "${control_plane_ref}" -${CONTAINER_ENGINE} tag "${web_console_local}" "${web_console_ref}" - if cluster_exists; then info "Loading images into Kind cluster..." - kind load docker-image "${api_server_ref}" --name "${KIND_CLUSTER_NAME}" - kind load docker-image "${control_plane_ref}" --name "${KIND_CLUSTER_NAME}" - kind load docker-image "${web_console_ref}" --name "${KIND_CLUSTER_NAME}" + tmpdir=$(mktemp -d /tmp/kind-images-XXXXXX) + for img in "${api_server_local}" "${control_plane_local}" "${web_console_local}"; do + archive="${tmpdir}/$(echo "${img}" | tr '/:' '__').tar" + ${CONTAINER_ENGINE} save "${img}" -o "${archive}" + kind load image-archive "${archive}" --name "${KIND_CLUSTER_NAME}" + done + rm -rf "${tmpdir}" success "Images loaded into Kind" fi diff --git a/scripts/kind/up.sh b/scripts/kind/up.sh index 8314690a..2891fdc3 100755 --- a/scripts/kind/up.sh +++ b/scripts/kind/up.sh @@ -199,7 +199,6 @@ echo "" FORCE_ROLLOUT="" if [[ "${LOCAL_IMAGES:-}" == "true" ]]; then header "Local Images" - info "Building baseline images from origin/main..." "${SCRIPT_DIR}/build-images.sh" FORCE_ROLLOUT=true echo "" @@ -240,8 +239,33 @@ echo "" # --- Deploy all components via kustomize --- header "Deploying Components" -info "Applying Kind manifests via kustomize..." -kustomize build deploy/kind | kube apply -f - +if [[ "${LOCAL_IMAGES:-}" == "true" ]]; then + info "Applying Kind manifests with localhost image refs..." + _kustomize_dir="deploy/.local-images" + mkdir -p "${_kustomize_dir}" + _registry="${IMAGE_REGISTRY:-quay.io/redhat-services-prod/hcm-eng-prod-tenant/hypershell-main}" + cat > "${_kustomize_dir}/kustomization.yaml" <-up` rebuilds from the working tree and replaces the deployment, even if already swapped; developers iterate by re-running the same target | | Web console as first-class component | Node.js frontend (`components/web-console/`) deployed alongside API server and control plane; supports hot reload via `KIND_HOT_RELOAD` for rapid UI iteration | | Hot reload on by default | Swap targets for supported components (web console) mount host source and run a dev server in an interactive TTY by default; `KIND_HOT_RELOAD=false` opts out to rebuild-and-replace. Keeps the same `kind--up` entrypoint for both workflows |