-
Notifications
You must be signed in to change notification settings - Fork 6
/
pull.sh
executable file
·98 lines (82 loc) · 2.34 KB
/
pull.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash -e
source conf.sh
source services.sh
function show_help {
echo "Usage: $0 [--version <version>] [--save] [<component>|all|data|coscale]"
echo " --version: overrides the version that is set in conf.sh"
echo " --save: creates coscale-<VERSION>.tar.gz that can be loaded on a different docker node"
echo
}
if [ "$1" == "--help" ]; then
show_help
exit 0
fi
if [ "$1" == "--version" ]; then
VERSION="$2"
shift #move command line arguments to the left
shift #move command line arguments to the left
fi
SAVE=false
if [ "$1" == "--save" ]; then
SAVE=true
shift
fi
if [ $# -gt 1 ]; then
show_help
exit 1
fi
NAME=${1:-all}
docker login -u "$REGISTRY_USERNAME" -p "$REGISTRY_PASSWORD" $REGISTRY
if [ "$NAME" == "base" ]; then
for SERVICE in base python java7 java8 rserve numpy; do
IMG=coscale/$SERVICE:1.1.0
docker pull $REGISTRY/$IMG
docker tag $REGISTRY/$IMG $IMG
done
exit 0
fi
function get_image {
SERVICE=$(echo $1 | grep -o -e '^[^0-9]*')
IMAGE_VERSION=$2
echo coscale/$SERVICE:$IMAGE_VERSION
}
function pull {
IMG=$1
docker pull $REGISTRY/$IMG
docker tag $REGISTRY/$IMG $IMG
}
IMAGES=""
# Pull the data services
for SERVICE in $DATA_SERVICES; do
if [ "$NAME" == "all" ] || [ "$NAME" == "data" ] || [ "$NAME" == "$SERVICE" ]; then
IMG=$(get_image $SERVICE $VERSION)
pull $IMG
IMAGES="$IMAGES $IMG"
fi
done
# Pull the coscale services
for SERVICE in $COSCALE_SERVICES $LB_SERVICE; do
if [ "$NAME" == "all" ] || [ "$NAME" == "coscale" ] || [ "$NAME" == "$SERVICE" ]; then
IMG=$(get_image $SERVICE $VERSION)
pull $IMG
IMAGES="$IMAGES $IMG"
fi
done
# Pull the extra containers
for EXTRA in diag postgresql-init; do
if [ "$NAME" == "all" ] || [ "$NAME" == "extra" ] || [ "$NAME" == "$EXTRA" ]; then
IMG=$(get_image $EXTRA $VERSION)
pull $IMG
IMAGES="$IMAGES $IMG"
fi
done
# Save the images to a tgz
if [ "$SAVE" == "true" ]; then
echo ""
echo "Using docker save to export the pulled images... This can take a few minutes..."
docker save -o coscale-${VERSION}.tar $IMAGES
echo "Gzipping the images... This can take a few minutes..."
gzip coscale-${VERSION}.tar
echo ""
echo "The image archive is available in coscale-${VERSION}.tar.gz"
fi