forked from cyber-dojo/saver
-
Notifications
You must be signed in to change notification settings - Fork 1
/
up.sh
executable file
·78 lines (69 loc) · 1.6 KB
/
up.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
78
#!/bin/bash -Eeu
export ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly SCRIPTS_DIR="${ROOT_DIR}/scripts"
source "${SCRIPTS_DIR}/augmented_docker_compose.sh"
source "${SCRIPTS_DIR}/config.sh"
source "${SCRIPTS_DIR}/echo_versioner_env_vars.sh"
source "${SCRIPTS_DIR}/exit_non_zero_unless_installed.sh"
# - - - - - - - - - - - - - - - - - - - -
# I would like to specify this size-limited tmpfs volume in
# the docker-compose.yml file:
#
# version: '3.7'
# saver:
# volumes:
# - type: tmpfs
# target: /one_k
# tmpfs:
# size: 1k
#
# but CircleCI does not support this yet.
# It currently supports up to 3.2
# So it is done like this:
#
# saver:
# volumes:
# - one_k:/one_k:rw
create_space_limited_volume()
{
docker volume create --driver local \
--opt type=tmpfs \
--opt device=tmpfs \
--opt o=size=1k \
one_k \
> /dev/null
}
# - - - - - - - - - - - - - - - - - - - -
service_up()
{
local -r service_name="${1}"
echo
augmented_docker_compose \
up \
--detach \
"${service_name}"
}
# - - - - - - - - - - - - - - - - - - - -
containers_down()
{
echo
augmented_docker_compose \
down \
--remove-orphans \
--volumes
}
# - - - - - - - - - - - - - - - - - - - -
containers_up()
{
create_space_limited_volume
service_up custom-start-points
service_up languages-start-points
service_up exercises-start-points
service_up $(server_name)
service_up $(client_name)
}
# - - - - - - - - - - - - - - - - - - - -
export $(echo_versioner_env_vars)
exit_non_zero_unless_installed docker docker-compose
containers_down
containers_up