forked from mreichelt/docker-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_deploy.sh
executable file
·98 lines (81 loc) · 3.05 KB
/
build_deploy.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
# abort on errors and on unset variables
set -e -o nounset
BASEIMAGE="kibatic/android-react-native"
SDKS=$(echo {29..21})
LATEST_SDKS=$(echo {29..27})
LATEST_PACKAGES=''; for SDK in $LATEST_SDKS; do LATEST_PACKAGES="platforms;android-${SDK} $LATEST_PACKAGES"; done
echo "SDKS = $SDKS"
echo "LATEST_SDKS = $LATEST_SDKS"
echo "LATEST_PACKAGES = $LATEST_PACKAGES"
docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
build_deploy_minimal() {
echo "Building 'minimal' image…"
docker pull $BASEIMAGE:minimal
docker build --cache-from $BASEIMAGE:minimal --tag $BASEIMAGE:minimal --file minimal.Dockerfile .
docker push $BASEIMAGE:minimal
echo
}
build_deploy_base() {
echo "Building 'base' image…"
docker pull $BASEIMAGE:base
docker build --cache-from $BASEIMAGE:base --tag $BASEIMAGE:base --file base.Dockerfile .
docker push $BASEIMAGE:base
echo
}
build_deploy_base_ndk() {
echo "Building 'base-ndk' image…"
docker pull $BASEIMAGE:base-ndk
docker build --cache-from $BASEIMAGE:base-ndk --tag $BASEIMAGE:base-ndk --file base-ndk.Dockerfile .
docker push $BASEIMAGE:base-ndk
echo
}
build_deploy_latest() {
echo "Building 'latest' image…"
docker pull $BASEIMAGE:latest
docker build --cache-from $BASEIMAGE:latest --tag $BASEIMAGE:latest --build-arg "latest_packages=${LATEST_PACKAGES}" --file latest.Dockerfile .
docker push $BASEIMAGE:latest
echo
}
build_deploy_latest_ndk() {
echo "Building 'latest-ndk' image…"
docker pull $BASEIMAGE:latest-ndk
docker build --cache-from $BASEIMAGE:latest-ndk --tag $BASEIMAGE:latest-ndk --file latest-ndk.Dockerfile .
docker push $BASEIMAGE:latest-ndk
echo
}
build_deploy_sdk_and_system() {
sdk=$1
echo "Building '$sdk-ndk' image…"
docker build --tag $BASEIMAGE:$sdk-ndk --build-arg android_sdk_version=$sdk --file sdk-ndk.Dockerfile .
echo "Pushing '$sdk-ndk' image…"
docker push $BASEIMAGE:$sdk-ndk
echo
echo "Building '$sdk' image…"
docker build --tag $BASEIMAGE:$sdk --build-arg android_sdk_version=$sdk --file sdk.Dockerfile .
echo "Pushing '$sdk' image…"
docker push $BASEIMAGE:$sdk
echo
echo "Building '$sdk-system' image…"
docker build --tag $BASEIMAGE:$sdk-system --build-arg android_sdk_version=$sdk --file sdk-system.Dockerfile .
echo "Pushing '$sdk-system' image…"
docker push $BASEIMAGE:$sdk-system
echo
echo "Deleting images '$sdk' and '$sdk-system'"
docker rmi $BASEIMAGE:$sdk $BASEIMAGE:$sdk-system
}
build_deploy_minimal
build_deploy_base
build_deploy_latest
build_deploy_base_ndk
build_deploy_latest_ndk
# remove some old images to save space on Travis CI
docker rmi \
$BASEIMAGE:minimal \
$BASEIMAGE:latest \
$BASEIMAGE:base-ndk \
$BASEIMAGE:latest-ndk
# build all sdk + system variants (in parallel because TravisCI has a 50m timeout)
export -f build_deploy_sdk_and_system
export BASEIMAGE
SHELL=$(type -p bash) parallel -j 2 --keep-order --line-buffer echo Building SDK {}\; build_deploy_sdk_and_system {} ::: $SDKS