-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathbuild-and-run.sh
More file actions
executable file
·62 lines (49 loc) · 1 KB
/
build-and-run.sh
File metadata and controls
executable file
·62 lines (49 loc) · 1 KB
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
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
port=9000
print_usage() {
cat << EOF
usage: ${0} [IMAGE...]
examples:
${0}
${0} 7.4-community
${0} 7.4-community-alpine
EOF
}
warn() {
echo "[warn] $*" >&2
}
fatal() {
echo "[error] $*" >&2
exit 1
}
require() {
local prog missing=()
for prog; do
if ! type "${prog}" &>/dev/null; then
missing+=("${prog}")
fi
done
[[ ${#missing[@]} = 0 ]] || fatal "could not find required programs on the path: ${missing[*]}"
}
require docker
for arg; do
if [[ "${arg}" == "-h" ]] || [[ "${arg}" == "--help" ]]; then
print_usage
exit
fi
done
if [[ $# = 0 ]]; then
print_usage
exit 1
fi
image="${1}"
image="${image%/}"
if ! [[ -d "${image}" ]]; then
warn "not a valid image, directory does not exist: ${image}"
exit 1
fi
name="sqtest:${image}"
docker build -t "${name}" -f "${image}/Dockerfile" "${PWD}/${image}"
docker run -p "${port}:9000" "${name}"