-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstart-local-env.sh
executable file
·74 lines (55 loc) · 1.69 KB
/
start-local-env.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
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/scripts/common-functions.sh"
export REVISION=${revision}
compose="docker compose -f docker-compose.yml"
if [ -d "$repo/../valtionavustus-secret/" ]; then
compose="$compose -f docker-compose.with-secret.yml"
fi
mkdir -p tmp
echo "${revision}" > "${repo}/tmp/version.txt"
compose="$compose -f docker-compose.local-dev.yml"
readonly compose
function stop() {
$compose down --remove-orphans || true
}
trap stop EXIT
function init {
require_command tmux
require_docker
}
function rename_panes_to_match_the_script_they_run {
tmux select-pane -t 0 -T run_database
tmux select-pane -t 1 -T run_frontend
tmux select-pane -t 2 -T run_hakija_server
tmux select-pane -t 3 -T run_fakesmtp
tmux select-pane -t 4 -T run_maksatuspalvelu
tmux select-pane -t 5 -T run_pagerduty
}
init
$compose create --build -- va db fakesmtp maksatuspalvelu pagerduty
session="valtionavustus"
tmux kill-session -t $session || true
tmux start-server
tmux new-session -d -s $session -c "$repo"
tmux splitw -h
tmux splitw -h
readonly up_cmd="$compose up --no-log-prefix --build"
tmux select-pane -t 0
tmux send-keys "$up_cmd db" C-m
tmux splitw -v
tmux select-pane -t 1
tmux send-keys "$repo/scripts/run_frontend.sh" C-m
tmux select-pane -t 2
tmux send-keys "NODE_VERSION=${NODE_VERSION} $up_cmd va" C-m
tmux select-pane -t 3
tmux send-keys "$up_cmd fakesmtp" C-m
tmux splitw
tmux select-pane -t 4
tmux send-keys "$up_cmd maksatuspalvelu" C-m
tmux splitw
tmux select-pane -t 5
tmux send-keys "$up_cmd pagerduty" C-m
rename_panes_to_match_the_script_they_run
tmux select-pane -t 0
tmux attach-session -t $session