-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·59 lines (53 loc) · 1.87 KB
/
deploy.sh
File metadata and controls
executable file
·59 lines (53 loc) · 1.87 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
#!/usr/bin/env bash
# ReadIO 一键部署:可选构建镜像 + 应用 K8s 清单
# 用法:
# ./deploy.sh # 仅部署(需已构建并加载镜像)
# ./deploy.sh --build # 先 Podman 构建四个镜像,再部署
# ./deploy.sh -b # 同上
# BUILD=1 ./deploy.sh # 同上
# MINIKUBE=1 ./deploy.sh # 部署前将本地镜像导入 minikube(需先构建)
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
K8S_FILE="${SCRIPT_DIR}/doc/k8s/all-in-one.yaml"
do_build() {
echo "==> Building images with Podman..."
cd "$SCRIPT_DIR"
podman build -f Dockerfile --build-arg MODULE=readio-auth -t readio-auth:latest .
podman build -f Dockerfile --build-arg MODULE=readio-admin -t readio-admin:latest .
podman build -f Dockerfile --build-arg MODULE=readio-portal -t readio-portal:latest .
podman build -f Dockerfile --build-arg MODULE=readio-gateway -t readio-gateway:latest .
echo "==> Build done."
}
do_minikube_load() {
if command -v minikube &>/dev/null && minikube status &>/dev/null; then
echo "==> Loading images into minikube..."
minikube image load readio-auth:latest
minikube image load readio-admin:latest
minikube image load readio-portal:latest
minikube image load readio-gateway:latest
echo "==> Minikube load done."
else
echo "==> Minikube not running or not in PATH, skip image load."
fi
}
do_deploy() {
if [[ ! -f "$K8S_FILE" ]]; then
echo "Error: $K8S_FILE not found." >&2
exit 1
fi
echo "==> Applying $K8S_FILE ..."
kubectl apply -f "$K8S_FILE"
echo "==> Deploy done. Check: kubectl get pods -n readio"
}
# Parse flags
BUILD="${BUILD:-0}"
MINIKUBE="${MINIKUBE:-0}"
for arg in "$@"; do
case "$arg" in
--build|-b) BUILD=1 ;;
--minikube|-m) MINIKUBE=1 ;;
esac
done
[[ "$BUILD" == "1" ]] && do_build
[[ "$MINIKUBE" == "1" ]] && do_minikube_load
do_deploy