-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-all-eve.sh
More file actions
executable file
·101 lines (80 loc) · 2.57 KB
/
build-all-eve.sh
File metadata and controls
executable file
·101 lines (80 loc) · 2.57 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
#!/usr/bin/env bash
set -euo pipefail
REGISTRY="${1:-}"
TAG="${TAG:?TAG env var is required (e.g. TAG=1.0.7 $0 [registry])}"
SSH_KEY="${SSH_KEY:-$HOME/.ssh/ztest_key.pub}"
if [ ! -f "$SSH_KEY" ]; then
echo "ERROR: SSH public key not found at ${SSH_KEY}"
echo "Set SSH_KEY to the path of your public key file"
exit 1
fi
SSH_KEY_CONTENT="$(cat "$SSH_KEY")"
echo "Using SSH public key: ${SSH_KEY}"
IMAGES=(
"eci-base:Dockerfile.base.eve:."
"caterpillar:caterpillar/Dockerfile.eve:."
"cyclictest:cyclictest/Dockerfile.eve:."
)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Resolve FQDN prefix: always include registry host, even for local builds
if [ -n "$REGISTRY" ]; then
FQDN_PREFIX="${REGISTRY}"
else
FQDN_PREFIX="docker.io/library"
fi
BUILT_TAGS=()
for entry in "${IMAGES[@]}"; do
IFS=: read -r name dockerfile context <<< "$entry"
local_tag="${name}:${TAG}"
echo "===> Building ${local_tag} from ${dockerfile} (context: ${context})"
docker build --network=host \
--build-arg BASE_TAG="${TAG}" \
--build-arg SSH_KEY="${SSH_KEY_CONTENT}" \
-f "$dockerfile" \
-t "$local_tag" \
"$context"
BUILT_TAGS+=("${FQDN_PREFIX}/${name}:${TAG}")
if [ -n "$REGISTRY" ]; then
remote_tag="${REGISTRY}/${name}:${TAG}"
remote_latest="${REGISTRY}/${name}:latest"
docker tag "$local_tag" "$remote_tag"
docker tag "$local_tag" "$remote_latest"
echo "===> Pushing ${remote_tag}"
docker push "$remote_tag"
echo "===> Pushing ${remote_latest}"
docker push "$remote_latest"
BUILT_TAGS+=("${REGISTRY}/${name}:latest")
fi
echo ""
done
echo ""
echo "BUILD SUMMARY"
echo ""
for entry in "${IMAGES[@]}"; do
IFS=: read -r name dockerfile context <<< "$entry"
local_tag="${name}:${TAG}"
size=$(docker image inspect "$local_tag" --format='{{.Size}}' 2>/dev/null || echo "0")
size_mb=$(( size / 1024 / 1024 ))
printf " %-50s %4s MB\n" "${FQDN_PREFIX}/${name}:${TAG}" "$size_mb"
if [ -n "$REGISTRY" ]; then
printf " %-50s %4s MB\n" "${REGISTRY}/${name}:latest" "$size_mb"
fi
done
echo ""
echo "QUICK START"
echo " SSH: ssh -i <key> root@<host>"
echo " Jupyter: ssh in, then run: jupyter-start"
echo " Preflight: ssh in, then run: rt-preflight"
echo ""
echo "ALL TAGS"
for t in "${BUILT_TAGS[@]}"; do
echo " $t"
done
echo ""
if [ -n "$REGISTRY" ]; then
echo "Status: built and pushed to ${REGISTRY}"
else
echo "Status: built locally (no registry, push skipped)"
fi
echo ""