-
Notifications
You must be signed in to change notification settings - Fork 20
/
demo.sh
executable file
·63 lines (53 loc) · 1.37 KB
/
demo.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
#!/usr/bin/env bash
set -Eeu
# Brings up a local server (without using commander).
repo_root() { git rev-parse --show-toplevel; }
readonly SH_DIR="$(repo_root)/sh"
source "${SH_DIR}/echo_versioner_env_vars.sh"
source "${SH_DIR}/exit_non_zero_unless_installed.sh"
source "${SH_DIR}/copy_in_saver_test_data.sh"
export $(echo_versioner_env_vars)
# - - - - - - - - - - - - - - - - - - - - - - -
docker_rm()
{
docker rm --force "${1}" 2> /dev/null || true
}
# - - - - - - - - - - - - - - - - - - - - - - -
web_build()
{
docker compose \
--file "$(repo_root)/docker-compose.yml" \
build \
--build-arg COMMIT_SHA="$(git_commit_sha)"
}
# - - - - - - - - - - - - - - - - - - - - - - -
git_commit_sha()
{
git rev-parse HEAD
}
# - - - - - - - - - - - - - - - - - - - - - - -
up_nginx()
{
docker compose \
--file "$(repo_root)/docker-compose-depends.yml" \
--file "$(repo_root)/docker-compose-nginx.yml" \
--file "$(repo_root)/docker-compose.yml" \
run \
--detach \
--name test_web_nginx \
--service-ports \
nginx
}
# - - - - - - - - - - - - - - - - - - - - - - - -
demo_URL()
{
echo "http://localhost:80/kata/edit/5U2J18"
}
# - - - - - - - - - - - - - - - - - - - - - - -
exit_non_zero_unless_installed docker
docker_rm test_web
web_build
docker_rm test_web_nginx
up_nginx
copy_in_saver_test_data # eg 5U2J18 (v1) 5rTJv5 (v0)
open "$(demo_URL)"