forked from SAP-archive/teched2020-developer-keynote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd
executable file
·72 lines (60 loc) · 1.18 KB
/
d
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
71
72
#!/usr/bin/env bash
# Docker utilities - d
set -o errexit
declare self applocation dockerreg tag
self=$(basename "$0")
applocation=router
dockerreg=https://docker.pkg.github.com
tag=docker.pkg.github.com/OWNER/REPOSITORY/s4mock:latest
usage() {
cat <<EOF
Usage: $self <action>
where <action> is one of:
- login: login to GitHub Packages
- build: create the Docker image
- run: run a container locally based on the image
- publish: publish the image to GitHub
EOF
}
login() {
local user pass
echo Authenticating with GitHub Packages
read -r -p "Enter username: " user
read -r -s -p "Enter password / token: " pass
echo
echo -n "$pass" \
| docker login $dockerreg \
--username "$user" \
--password-stdin
}
build() {
echo Building image for "$applocation"
docker build \
-t $tag \
-f ./Dockerfile \
$applocation
}
run() {
echo Running detached instance of image locally
docker run \
-d \
-p 5000:5000 \
$tag
}
publish() {
echo Publishing image to GitHub Packages
docker push \
$tag
}
main() {
local action=$1
case $action in
login|build|run|publish)
$action
;;
*)
usage
exit 1
esac
}
main "$@"