forked from tarantool/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-image.sh
executable file
·99 lines (76 loc) · 2.4 KB
/
build-image.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
99
#!/usr/bin/env bash
function build_and_push()
{
local repo=$1
local branch=$2
local version=$3
local major=$4
local minor=$5
local tail=$6
echo "Will build $version$tail from branch: $branch"
docker build \
-t "$repo":"$major""$tail" \
-t "$repo":"$minor""$tail" \
-t "$repo":"$version""$tail" \
--build-arg TARANTOOL_VERSION="$version" \
--build-arg TARANTOOL_BRANCH="$branch" \
.
# docker run --rm --entrypoint=/usr/local/bin/tarantool $repo:$version$tail \
# | grep "Tarantool $version"
docker push "$repo":"$major""$tail"
docker push "$repo":"$minor""$tail"
docker push "$repo":"$version""$tail"
}
REPOSITORY=progaudi/tarantool
set -e
pushd "${BASH_SOURCE%/*}/"
if [ ! -d .tarantool/.git ]
then
rm -rf .tarantool
git clone git://github.com/tarantool/tarantool.git .tarantool
fi
pushd .tarantool
git checkout "$TARANTOOL_BRANCH"
git pull
git tag | grep -v "$TARANTOOL_BRANCH" | xargs -I {} git tag -d {}
TARANTOOL_VERSION=$(git describe --long || echo "no version")
popd
if [ "$TARANTOOL_VERSION" == "no version" ]
then
echo "No version to build, possible a feature branch. Skipping it."
exit 0
fi
# TARANTOOL_VERSION: 1.6.9-11-gf4619d0, 1.7.5-0-g24b70de10, 1.8.1-415-ge3d2485c7
# TARANTOOL_VERSION=1.7.5-0-g24b70de10
# split by .
IFS=. read -ra version_slugs <<< "$TARANTOOL_VERSION"
if [ ${#version_slugs[@]} != 3 ]; then
echo "Can't parse tarantool version. Set TARANTOOL_VERSION environment variable "
exit 1
fi
major=${version_slugs[0]}.${version_slugs[1]}
# split by -
IFS=- read -ra minor_slugs <<< "${version_slugs[2]}"
if [ ${#minor_slugs[@]} != 3 ]; then
echo "Can't parse tarantool version. Set TARANTOOL_VERSION environment variable "
exit 2
fi
minor=$major.${minor_slugs[0]}
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
set -x
for dir in "$TARANTOOL_DIRECTORY"* ;
do
pushd "$dir"
tail=${dir#$TARANTOOL_DIRECTORY}
if [ ! -z "$FORCE_BUILD" ]
then
build_and_push $REPOSITORY "$TARANTOOL_BRANCH" "$TARANTOOL_VERSION" "$major" "$minor" "$tail"
elif docker pull $REPOSITORY:"$TARANTOOL_VERSION""$tail"
then
echo "$TARANTOOL_VERSION$tail is already built. Rebuild it manually."
else
build_and_push $REPOSITORY "$TARANTOOL_BRANCH" "$TARANTOOL_VERSION" "$major" "$minor" "$tail"
fi
popd
done
popd