Repository navigation
Expand file tree
/
Copy pathremote_up.sh
More file actions
executable file
·79 lines (64 loc) · 1.69 KB
/
Copy pathremote_up.sh
File metadata and controls
executable file
·79 lines (64 loc) · 1.69 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
75
76
77
78
79
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LIB_PATH="$SCRIPT_DIR/scripts/lib/setup_common.sh"
BOOTSTRAP_LIB=""
if [[ ! -f "$LIB_PATH" ]]; then
BOOTSTRAP_LIB="$(mktemp)"
curl -fsSL -o "$BOOTSTRAP_LIB" "https://raw.githubusercontent.com/dograh-hq/dograh/main/scripts/lib/setup_common.sh"
LIB_PATH="$BOOTSTRAP_LIB"
fi
cleanup() {
if [[ -n "$BOOTSTRAP_LIB" ]]; then
rm -f "$BOOTSTRAP_LIB"
fi
}
trap cleanup EXIT
# shellcheck disable=SC1090
. "$LIB_PATH"
DOGRAH_DEPLOY_PROJECT_DIR="$SCRIPT_DIR"
VALIDATE_ONLY=0
MODE="pull"
EXTRA_ARGS=()
while [[ $# -gt 0 ]]; do
case "$1" in
--build)
MODE="build"
;;
--preflight-only|--validate-only)
VALIDATE_ONLY=1
;;
--)
shift
EXTRA_ARGS=("$@")
break
;;
*)
EXTRA_ARGS+=("$1")
;;
esac
shift
done
cd "$SCRIPT_DIR"
dograh_info "Running Dograh remote preflight..."
dograh_prepare_remote_install "$SCRIPT_DIR"
docker compose config -q
dograh_success "✓ dograh-init preflight validated"
if [[ "$VALIDATE_ONLY" == "1" ]]; then
exit 0
fi
if [[ $EUID -eq 0 ]] || ! command -v sudo >/dev/null 2>&1; then
COMPOSE_CMD=(docker compose)
else
COMPOSE_CMD=(sudo docker compose)
fi
if [[ "$MODE" == "build" ]]; then
CMD=("${COMPOSE_CMD[@]}" --profile remote up -d --build --force-recreate)
else
CMD=("${COMPOSE_CMD[@]}" --profile remote up -d --pull always --force-recreate)
fi
# Bash 3.2 on macOS treats "${empty_array[@]}" as unbound under `set -u`.
if (( ${#EXTRA_ARGS[@]} )); then
CMD+=("${EXTRA_ARGS[@]}")
fi
exec "${CMD[@]}"