-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdocker_build.sh
executable file
·67 lines (56 loc) · 1.58 KB
/
docker_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
67
#!/bin/bash
set -e
# Update version when changes to Dockerfile are made
DOCKER_IMAGE_VERSION=1.0.0
TIMESTAMP=$(date +"%s")
DIR=$(cd $(dirname $0) && pwd)
# Registries and tags
GCR_URL="us.gcr.io/broad-gotc-prod/sctools"
# sctools version
SCTOOLS_VERSION="v0.3.15"
# Necessary tools and help text
TOOLS=(docker gcloud)
HELP="$(basename "$0") [-h|--help] [-v|--version] [-t|tools] -- script to build the sctools image and push to GCR & Quay
where:
-h|--help Show help text
-v|--version Version of Samtools to use (default: $SCTOOLS_VERSION)
-t|--tools Show tools needed to run script
"
function main(){
for t in "${TOOLS[@]}"; do which "$t" >/dev/null || ok=no; done
if [[ $ok == no ]]; then
echo "Missing one of the following tools: "
for t in "${TOOLS[@]}"; do echo "$t"; done
exit 1
fi
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-v|--version)
SCTOOLS_VERSION="$2"
shift
shift
;;
-h|--help)
echo "$HELP"
exit 0
;;
-t|--tools)
for t in "${TOOLS[@]}"; do echo "$t"; done
exit 0
;;
*)
shift
;;
esac
done
IMAGE_TAG="$DOCKER_IMAGE_VERSION-$SCTOOLS_VERSION-$TIMESTAMP"
echo "building and pushing GCR Image - $GCR_URL:$IMAGE_TAG"
docker build --no-cache -t "$GCR_URL:$IMAGE_TAG" \
--build-arg SCTOOLS_VERSION="$SCTOOLS_VERSION" "$DIR"
docker push "$GCR_URL:$IMAGE_TAG"
echo -e "$GCR_URL:$IMAGE_TAG" >> "$DIR/docker_versions.tsv"
echo "done"
}
main "$@"