-
Notifications
You must be signed in to change notification settings - Fork 2
/
mkit-wrapper.sh
executable file
·45 lines (35 loc) · 1011 Bytes
/
mkit-wrapper.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
#!/bin/bash
#
# File: mkit-wrapper.sh
# Created: 270718
#
### FUNCTIONS ###
docker_hub()
{
typeset target="$1"
[ -z "$DOCKER_PASSWORD" -o -z "$DOCKER_USERNAME" ] && { echo "docker_hub: Docker environment not set-up correctly"; return 1; }
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
rc=$?
[ $rc -ne 0 ] && { echo "docker_hub: Docker hub login failed with rc = $rc"; return $rc; }
}
docker_push()
{
[ ! -z "$target" ] && { docker push "$target"; return $?; }
return 0
}
### ENV ###
isdocker="$1"; shift
image="${1:-${DOCKER_IMAGE}}"; shift
prefix="${1:-${PREFIX}}"; shift
prefix="${prefix:-/app/httpd}" # sanity check
### MAIN ###
[ "$isdocker" == "yes" ] &&
{
docker_hub || return $?
docker build -t "$image" --build-arg PROFILE=$PROFILE --build-arg PREFIX=$prefix .
build_rc="$?"
[ $build_rc -eq 0 -a ! -z "$image" ] && docker_push "$image"
exit $build_rc
} ||
{ ./run-workflow.sh "$prefix"; exit $?; }
### EOF ###