This repository has been archived by the owner on Jul 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 220
/
cli.sh
executable file
·77 lines (71 loc) · 1.56 KB
/
cli.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
usage() {
cat << EOF
Usage: $(basename $0) COMMAND
config [OPTIONS] Run the CLI tool
--no-current-user Run as root (Docker default) instead of the current user
up [OPTIONS] Build, (re)create, and start all services in the background
--dry-run Disable Certbot to run all services locally
build [OPTIONS] Build or rebuild all Docker images
--no-cache Do not use cache when building the images
EOF
exit 1
}
case $1 in
config)
CMD=(docker compose run --rm cli)
export CURRENT_USER="$(id -u):$(id -g)"
export DOCKER_GROUP="$(getent group docker | cut -d: -f3)"
shift
while [[ $# -gt 0 ]]; do
case $1 in
--no-current-user)
unset CURRENT_USER
unset DOCKER_GROUP
shift
;;
*)
echo "Unknown option $1"
usage
;;
esac
done
;;
up)
CMD=(docker compose up -d)
shift
while [[ $# -gt 0 ]]; do
case $1 in
--dry-run)
export DRY_RUN=true
shift
;;
*)
echo "Unknown option $1"
usage
;;
esac
done
;;
build)
CMD=(docker compose --profile config build)
shift
while [[ $# -gt 0 ]]; do
case $1 in
--no-cache)
CMD+=(--no-cache)
shift
;;
*)
echo "Unknown option $1"
usage
;;
esac
done
;;
*)
echo "Unknown command $1"
usage
;;
esac
"${CMD[@]}"