This repository has been archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprepare-syntho-images.sh
executable file
·78 lines (62 loc) · 2.69 KB
/
prepare-syntho-images.sh
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
#!/bin/bash
if [ "$#" -lt 2 ]; then
echo "Usage: $0 --mode <save/load> --tag <tag> --path <path>
Example: ./prepare-syntho-images.sh --mode save --tag latest --path /home/syntho/images
Example: ./prepare-syntho-images.sh --mode load --tag latest --path /home/syntho/images"
exit 1
fi
# Parse command line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--mode)
mode="$2"
shift 2
;;
--tag)
tag="$2"
shift 2
;;
--path)
path="$2"
shift 2
;;
*)
usage
;;
esac
done
# Check if required arguments are provided
if [ -z "$mode" ] || [ -z "$tag" ] || [ -z "$path" ]; then
usage
fi
if [ "${path: -1}" != "/" ]; then
path="${path}/"
fi
if [ "$mode" = "save" ]; then
docker pull "syntho.azurecr.io/postgres:${tag}"
docker save "syntho.azurecr.io/postgres:${tag}" > "${path}postgres.tar"
docker pull redis:6.2-alpine
docker save redis:6.2-alpine > "${path}redis.tar"
docker pull "syntho.azurecr.io/syntho-core-api:${tag}"
docker save "syntho.azurecr.io/syntho-core-api:${tag}" > "${path}syntho-core-api.tar"
docker pull "syntho.azurecr.io/syntho-core-backend:${tag}"
docker save "syntho.azurecr.io/syntho-core-backend:${tag}" > "${path}syntho-core-backend.tar"
docker pull "syntho.azurecr.io/syntho-core-frontend:${tag}"
docker save "syntho.azurecr.io/syntho-core-frontend:${tag}" > "${path}syntho-core-frontend.tar"
docker pull "syntho.azurecr.io/syntho-ray:${tag}-cpu"
docker save "syntho.azurecr.io/syntho-ray:${tag}-cpu" > "${path}syntho-ray.tar"
docker pull "syntho.azurecr.io/syntho-ray-operator:${tag}"
docker save "syntho.azurecr.io/syntho-ray-operator:${tag}" > "${path}syntho-ray-operator.tar"
tar -cvf "${path}syntho-images.tar" -C ${path} postgres.tar redis.tar syntho-core-api.tar syntho-core-backend.tar syntho-core-frontend.tar syntho-ray.tar syntho-ray-operator.tar
rm "${path}postgres.tar" "${path}redis.tar" "${path}syntho-core-api.tar" "${path}syntho-core-backend.tar" "${path}syntho-core-frontend.tar" "${path}syntho-ray.tar" "${path}syntho-ray-operator.tar"
elif [ "$mode" = "load" ]; then
tar -xvf "${path}syntho-images.tar" -C ${path}
docker load < "${path}redis.tar"
docker load < "${path}postgres.tar"
docker load < "${path}syntho-core-api.tar"
docker load < "${path}syntho-core-backend.tar"
docker load < "${path}syntho-core-frontend.tar"
docker load < "${path}syntho-ray.tar"
docker load < "${path}syntho-ray-operator.tar"
rm "${path}postgres.tar" "${path}redis.tar" "${path}syntho-core-api.tar" "${path}syntho-core-backend.tar" "${path}syntho-core-frontend.tar" "${path}syntho-ray.tar" "${path}syntho-ray-operator.tar"
fi