-
Notifications
You must be signed in to change notification settings - Fork 0
/
do.sh
executable file
·77 lines (67 loc) · 1.55 KB
/
do.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
#!/usr/bin/env bash
# settings
PROJECT_NAME="DJANGOCMS_HTML_TAGS"
# colors
BLUE="\\033[1;34m"
GREEN="\\033[1;32m"
NORMAL="\\033[0;39m"
print_help() {
echo -e "${BLUE}Available environments${NORMAL}"
echo " - DEV (default)"
echo " - PROD"
echo " - STAGING"
echo ""
echo -e "${BLUE}Available commands${NORMAL}"
echo -e " > docker [:command] Run a Docker command."
echo -e " > runtests Run unit tests."
echo -e " > shell Open Bash session in the backend service."
}
docker_command() {
command="docker-compose -p ${PROJECT_NAME} -f docker/docker-compose.yml "
case ${ENV} in
"PROD")
file_prefix="prod"
;;
"STAGING")
file_prefix="staging"
;;
*)
file_prefix="dev"
;;
esac
command+="-f docker/docker-compose.${file_prefix}.yml ${@}"
echo -e "${BLUE} Command: ${NORMAL}${command}"
echo -e ""
eval ${command}
}
docker() {
docker_command ${@}
}
runtests() {
test_command="'
coverage run setup.py test &&
coverage html
'"
docker_command run --rm backend sh -c ${test_command}
}
shell() {
docker_command run --rm backend bash
}
if [ -z ${1} ]
then
print_help
else
case ${ENV} in
"PROD")
env_str="production"
;;
"STAGING")
env_str="staging"
;;
*)
env_str="development"
;;
esac
echo -e "${BLUE}Environment:${NORMAL} ${env_str}"
${@}
fi