-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·53 lines (47 loc) · 1.06 KB
/
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
#!/usr/bin/env bash
except() {
local message
message="$1"
readonly message
printf "Error! - " + "${message}"
+ "\nBuild process will now exit."
exit 1
}
configure() {
local path
local image_name
path="$1"
image_name="$2"
readonly path
readonly image_name
build "${path}" "${image_name}" || except "Docker Build Failed, see journalctl and build.log for more information."
}
build() {
local path
local image_name
path="$1"
image_name="$2"
readonly path
readonly image_name
docker build --pull -t "${image_name}" "${path}" 2>&1 | tee "${path}"/build.log
}
push() {
local name
name="$1"
readonly name
docker push "${name}"
}
main() {
local path
local timestamp
local name
path="${USERHOME}"/docker/kali
readonly path
timestamp=$(/usr/bin/date +%Y%m%d_%H%M)
readonly timestamp
name="docker.io/blairy/kali-ready-to-roll:""${timestamp}"
readonly name
configure "${path}" "${name}" || except "Failed to configure the image name and path."
push "${name}" || except "Failed to push image to Docker hub"
}
main "$@"