-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-and-release.sh
executable file
·56 lines (49 loc) · 1.04 KB
/
build-and-release.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
#!/bin/bash
set -e
AUTHOR="uptimeproject"
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
MODE=${1:--local}
function print_info {
printf $GREEN
printf "$1\n"
printf $NC
}
function print_error {
printf $RED
printf "$1\n"
printf $NC
}
function deploy {
CONTEXT=$1
FILE="$1/$2"
IMAGE="$AUTHOR/$1"
TAG=$(printf $2 | sed 's/\.[^.]*$//')
print_info "Building image $IMAGE:$TAG"
docker build -t $IMAGE:$TAG --file $FILE $CONTEXT
if [ "$MODE" = "--release" ]; then
print_info "Releasing image $IMAGE:$TAG"
docker push $IMAGE:$TAG
fi
}
# Run
if [ "$MODE" = "--release" ]; then
print_info "\nBUILD AND RELEASE CONTAINERS\n"
else
print_info "\nBuild containers locally\n"
fi
for build_context in *; do
if [ -d "$build_context" ]; then
print_info "Checking build context '$build_context' for dockerfiles.."
cd $build_context
for dockerfile in *.dockerfile; do
if [ -f "$dockerfile" ]; then
cd ..
deploy $build_context $dockerfile
cd $build_context
fi
done
cd ..
fi
done