-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·38 lines (35 loc) · 1.07 KB
/
build.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
#!/bin/bash
IMAGE="simple-todo"
REPO="sokubedocker"
build_version () {
feature_file=$(echo "./features/$1")
if [ -f "$feature_file" ]; then
version=$1
echo "-------------------------------------------------------------------------------"
echo "Building version $1 with features file=$feature_file"
cp -f "$feature_file" features.json
docker build --no-cache=true --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -t "$REPO/$IMAGE:$version" .
else
echo "Version $1 does not exist in ./features/"
fi
}
push_version () {
version=$1
echo "-------------------------------------------------------------------------------"
echo "Pushing $REPO/$IMAGE:$version"
docker push "$REPO/$IMAGE:$version"
}
if [ ! -z "$1" ]; then
build_version $1
if [ "$2" == "--push" ]; then
push_version $1
fi
else
for f in ./features/*; do
version=$(echo "$f" | cut -d '/' -f 3 )
build_version $version
if [ "$2" == "--push" ]; then
push_version $version
fi
done
fi