-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathops
More file actions
executable file
·74 lines (60 loc) · 1.97 KB
/
ops
File metadata and controls
executable file
·74 lines (60 loc) · 1.97 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
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
if which podman >/dev/null; then
CONMAN="$(which podman)"
if which buildah >/dev/null; then
BUILDCON=("$(which buildah)" bud)
fi
elif which docker >/dev/null; then
CONMAN="$(which docker)"
BUILDCON=("$CONMAN" build)
fi
CONREG="dkcr.nl"
SELF="$(realpath "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}")"
DIR="$(dirname "$SELF")"
VENDOR="$(basename "$(dirname "$DIR")")"
PROJECT="$(basename "$DIR")"
IMAGE="$CONREG/$VENDOR/$PROJECT"
VOLUMES=(-w "/opt/$VENDOR/$PROJECT" "-v" "$DIR:/opt/$VENDOR/$PROJECT:rw")
if ! "$CONMAN" images | grep -q "$IMAGE"; then
"${BUILDCON[@]}" -t $IMAGE -f Containerfile .
fi
case "${1:-}" in
build)
"${BUILDCON[@]}" -t $IMAGE -f Containerfile .
;;
update | require | install)
"$CONMAN" run -it --rm -v "$DIR:/app:rw" composer composer "$@"
;;
test)
shift
"$CONMAN" run -it --rm "${VOLUMES[@]}" "$IMAGE" \
php /opt/$VENDOR/$PROJECT/vendor/bin/phpunit --coverage-html "/opt/$VENDOR/$PROJECT/docs/coverage" /opt/$VENDOR/$PROJECT/tests $*
;;
check)
"$CONMAN" run -it --rm "${VOLUMES[@]}" "$IMAGE" \
find src tests -name "*.php" -type f -exec php -l "{}" \;
;;
bash)
"$CONMAN" run -it --rm "${VOLUMES[@]}" "$IMAGE" bash
;;
php)
shift
"$CONMAN" run -it --rm "${VOLUMES[@]}" "$IMAGE" php "$@"
;;
proof)
shift
"$CONMAN" run -it --rm "${VOLUMES[@]}" -p 8080:8080 "$IMAGE" php "$@"
;;
coverage)
"$CONMAN" run --name "${VENDOR}_${PROJECT}" -d --rm "${VOLUMES[@]}" -p 8080:8080 "$IMAGE" php -S 0.0.0.0:8080 coverage.php >/dev/null
echo "Goto http://$(ip addr show eth0 | sed -n 's/^ *inet \([^/]*\).*$/\1/p'):8080"
;;
""|help|--help|-h|-?)
echo "Usage: $0 ( login | build | update | require | test | check | bash | coverage)"
;;
*)
echo "No such subcommand: $@"
;;
esac