-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·40 lines (34 loc) · 941 Bytes
/
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
#!/bin/bash
build_no="$1"
build_args="--compress"
tag_prefix="registry.library.oregonstate.edu/osulp-api"
if [ -z "$BCR_PASS" ]; then
echo 'Please set the BCR password in $BCR_PASS'
exit 1
fi
if [ -z "$build_no" ]; then
if [ -f ".version" ]; then
version=`cat .version`
let build_no=($version + 1)
echo "Using cached build number: (old: $version, new: $build_no)"
else
echo "Usage: $0 <build number>"
exit 1
fi
fi
tag1="$tag_prefix:osulp-${build_no}"
tag2="$tag_prefix:latest"
echo "Building for tag $tag1"
docker build ${build_args} . -t "$tag1"
if [ "$?" -eq 0 ]; then
echo "Logging into BCR as admin"
echo $BCR_PASS | docker login --password-stdin registry.library.oregonstate.edu
echo "pushing: $tag1"
docker push "$tag1"
if [ "$?" -eq 0 ]; then
echo $build_no > .version
fi
echo "tagging $tag1 as :latest"
docker tag $tag1 $tag2
docker push "$tag2"
fi