forked from tpruvot/ccminer
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmake-docker.sh
executable file
·70 lines (61 loc) · 1.85 KB
/
make-docker.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
68
69
70
#!/bin/sh
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# receive tag as argument
create_docker_image () {
tag="$1"
echo 'building docker image'
docker build -t panamera:"$tag" "$DIR"
}
# receive tag as argument
push_image () {
echo 'Pushing image to repository'
tag="$1"
docker tag panamera:"$tag" 537254410709.dkr.ecr.us-east-1.amazonaws.com/panamera:"$tag"
docker push 537254410709.dkr.ecr.us-east-1.amazonaws.com/panamera:"$tag"
}
# Initialize all the option variables.
# This ensures we are not contaminated by variables from the environment.
tag='latest'
push=false
while :; do
case $1 in
-h|-\?|--help)
# display use help
printf '%s [-t tag_name, --tag=tag_name] [-p, --push]\n' "$0"
exit
;;
-t|--tag) # Takes an option argument; ensure it has been specified.
if [ "$2" ]; then
tag=$2
shift
else
printf 'ERROR: "--tag" requires a non-empty option argument.\n'
exit 1
fi
;;
--tag=?*)
tag=${1#*=} # Delete everything up to "=" and assign the remainder.
;;
--tag=) # Handle the case of an empty --tag=
printf 'ERROR: "--tag" requires a non-empty option argument.\n'
exit 1
;;
-p|--push)
push=true
;;
-?*)
printf 'ERROR: Unknown option: %s\n' "$1" >&2
exit 1
;;
*) # Default case: No more options, so break out of the loop.
break
esac
shift
done
create_docker_image "$tag"
if [ "$push" = true ] ; then
push_image "$tag"
else
echo 'Image has not been pushed to the repository. If you would like to do so, run with --push'
fi
echo 'Done!'