-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathlocal-build-and-test.sh
More file actions
executable file
·114 lines (101 loc) · 4.56 KB
/
local-build-and-test.sh
File metadata and controls
executable file
·114 lines (101 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
set -e
# Local Build and Test Script for JWT-SVID Authentication
# This script builds all necessary images locally and loads them into Kind
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
KAGENTI_DIR="${KAGENTI_DIR:-$(cd "$SCRIPT_DIR/../kagenti" 2>/dev/null && pwd || echo "")}"
if [ -z "$KAGENTI_DIR" ] || [ ! -d "$KAGENTI_DIR" ]; then
echo "ERROR: Set KAGENTI_DIR to point to your kagenti repo clone"
exit 1
fi
CLUSTER_NAME="${CLUSTER_NAME:-kagenti-dev}"
# Auto-detect container runtime (Podman or Docker)
# If KIND_EXPERIMENTAL_PROVIDER is set to podman, use it regardless of what's installed
if [ "${KIND_EXPERIMENTAL_PROVIDER}" = "podman" ]; then
CONTAINER_RUNTIME="${CONTAINER_RUNTIME:-podman}"
elif ! command -v docker &> /dev/null && command -v podman &> /dev/null; then
# Docker not available but Podman is
CONTAINER_RUNTIME="${CONTAINER_RUNTIME:-podman}"
else
CONTAINER_RUNTIME="${CONTAINER_RUNTIME:-docker}"
fi
echo "Using container runtime: ${CONTAINER_RUNTIME}"
# Function to load image into Kind (handles Podman vs Docker)
load_image_to_kind() {
local image_name="$1"
if [ "${CONTAINER_RUNTIME}" = "podman" ]; then
# Podman: save to tar and load
# Replace colons and slashes to make valid filename
local tar_file="/tmp/$(echo ${image_name} | sed 's|[:/]|-|g').tar"
${CONTAINER_RUNTIME} save "${image_name}" -o "${tar_file}"
kind load image-archive "${tar_file}" --name "${CLUSTER_NAME}"
rm -f "${tar_file}"
else
# Docker: direct load
kind load docker-image "${image_name}" --name "${CLUSTER_NAME}"
fi
}
echo "=========================================="
echo "Building Local Images for JWT-SVID Testing"
echo "Cluster: ${CLUSTER_NAME}"
echo "=========================================="
# Check if cluster exists
if ! kind get clusters | grep -q "^${CLUSTER_NAME}$"; then
echo "❌ Kind cluster '${CLUSTER_NAME}' not found"
echo "Please create it first or set CLUSTER_NAME environment variable"
exit 1
fi
echo "✅ Found Kind cluster: ${CLUSTER_NAME}"
echo ""
# Build spiffe-idp-setup (NEW - from kagenti repo)
echo "=========================================="
echo "Building spiffe-idp-setup"
echo "=========================================="
cd "${KAGENTI_DIR}/kagenti/auth/spiffe-idp-setup"
${CONTAINER_RUNTIME} build -t ghcr.io/kagenti/kagenti/spiffe-idp-setup:local .
load_image_to_kind ghcr.io/kagenti/kagenti/spiffe-idp-setup:local
echo "✅ Built and loaded: spiffe-idp-setup:local"
echo ""
# Build client-registration (CHANGED - UID 1000)
echo "=========================================="
echo "Building client-registration"
echo "=========================================="
cd "${SCRIPT_DIR}/authbridge/client-registration"
${CONTAINER_RUNTIME} build -t ghcr.io/kagenti/kagenti-extensions/client-registration:local .
load_image_to_kind ghcr.io/kagenti/kagenti-extensions/client-registration:local
echo "✅ Built and loaded: client-registration:local"
echo ""
# Build envoy-with-processor (Envoy runs as UID 1337)
echo "=========================================="
echo "Building envoy-with-processor"
echo "=========================================="
cd "${SCRIPT_DIR}/authbridge/authproxy"
${CONTAINER_RUNTIME} build -f Dockerfile.envoy -t ghcr.io/kagenti/kagenti-extensions/envoy-with-processor:local .
load_image_to_kind ghcr.io/kagenti/kagenti-extensions/envoy-with-processor:local
echo "✅ Built and loaded: envoy-with-processor:local"
echo ""
# Build proxy-init
echo "=========================================="
echo "Building proxy-init"
echo "=========================================="
cd "${SCRIPT_DIR}/authbridge/authproxy"
${CONTAINER_RUNTIME} build -f Dockerfile.init -t ghcr.io/kagenti/kagenti-extensions/proxy-init:local .
load_image_to_kind ghcr.io/kagenti/kagenti-extensions/proxy-init:local
echo "✅ Built and loaded: proxy-init:local"
echo ""
echo "=========================================="
echo "✅ All images built and loaded successfully!"
echo "=========================================="
echo ""
echo "Images loaded into cluster '${CLUSTER_NAME}':"
echo " - ghcr.io/kagenti/kagenti/spiffe-idp-setup:local"
echo " - ghcr.io/kagenti/kagenti-extensions/client-registration:local"
echo " - ghcr.io/kagenti/kagenti-extensions/envoy-with-processor:local"
echo " - ghcr.io/kagenti/kagenti-extensions/proxy-init:local"
echo ""
echo "Next steps:"
echo " 1. Update values files to use :local tag"
echo " 2. Run: cd ${KAGENTI_DIR} && deployments/ansible/run-install.sh --env dev"
echo " 3. Verify SPIRE and Keycloak are running"
echo " 4. Run the AuthBridge demo"
echo ""