-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
66 lines (53 loc) · 1.66 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
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
#!/usr/bin/env bash
# resulting images namespace on docker hub
NAMESPACE=alpinium
# publish the built images
PUBLISH=true
# enabled repositories for the build
REPOSITORIES=$1
# enable all repositories if any specified
if [[ -z $REPOSITORIES ]]; then
REPOSITORIES="base node"
fi
# for returning later to the main directory
ROOT_DIRECTORY=`pwd`
# function for building images
function build_repository {
# read repository configuration
source $ROOT_DIRECTORY/$REPOSITORY/buildvars
# build all enabled versions
for TAG in $TAGS; do
# some verbose
echo $'\n\n'"--> Building $NAMESPACE/$REPOSITORY:$TAG"$'\n'
cd $ROOT_DIRECTORY/$REPOSITORY/$TAG
docker build -t $NAMESPACE/$REPOSITORY:$TAG .
done
# create the latest tag
echo $'\n\n'"--> Aliasing $LATEST as 'latest'"$'\n'
docker tag $NAMESPACE/$REPOSITORY:$LATEST $NAMESPACE/$REPOSITORY:latest
}
# function for publishing images
function publish_repository {
# read repository configuration
source $ROOT_DIRECTORY/$REPOSITORY/buildvars
# publish all enabled versions
for TAG in $TAGS; do
# some verbose
echo $'\n\n'"--> Publishing $NAMESPACE/$REPOSITORY:$TAG"$'\n'
# publish
docker push $NAMESPACE/$REPOSITORY:$TAG
done
# create the latest tag
echo $'\n\n'"--> Publishing $NAMESPACE/$REPOSITORY:latest (from $LATEST)"$'\n'
docker push $NAMESPACE/$REPOSITORY:latest
}
# for each enabled repository
for REPOSITORY in $REPOSITORIES; do
# build the repository
build_repository $REPOSITORY
# If publishing is enabled
if [ $PUBLISH == true ]; then
# Push the built image
publish_repository $REPOSITORY
fi
done