-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.sh
executable file
·35 lines (30 loc) · 1.01 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
#!/bin/bash
set -ex
REGISTRY="argo.registry:5000"
BRANCH=$1
for d in */ ; do
if [[ "$d" == "utils/" ]]; then
continue;
fi
echo '>>> Build Image: ' $d
# Get version and image name
VERSION=`cat $d/VERSION`
IMAGE=`echo ${d%/}`
echo '>>> Image:' $IMAGE:$VERSION
version_exists=`curl $REGISTRY/v2/$IMAGE/tags/list | grep "${VERSION}" ; exit 0`
if [[ "$version_exists" == *"$VERSION"* ]]; then
echo ">>> Skiping build. Image version already exists in registry"
continue;
fi
# Build Docker image and tag version
docker build -f $IMAGE/Dockerfile . -t $IMAGE:latest --no-cache
docker tag $IMAGE:latest $IMAGE:$VERSION
# Push to docker registry
if [ "$BRANCH" == "master" ]; then
echo ">>> Pushing image to docker registry"
docker tag $IMAGE:latest $REGISTRY/$IMAGE:latest
docker tag $IMAGE:$VERSION $REGISTRY/$IMAGE:$VERSION
docker push $REGISTRY/$IMAGE:$VERSION
docker push $REGISTRY/$IMAGE:latest
fi
done