-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdo.sh
executable file
·146 lines (101 loc) · 2.98 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
COLUMNS="`tput cols`"
LINES="`tput lines`"
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
DOCKER_COMPOSE="docker compose"
_requires() {
service="$1"
$DOCKER_COMPOSE ps -q $service &> /dev/null
if [[ "$?" == 1 ]]; then
echo "'$service' service is not running. Please run \`start\` first."
exit 1
fi
}
bounce() {
stop
build
start
}
build() {
$DOCKER_COMPOSE build --force-rm \
"${@:1}"
}
check() {
_requires djangosocial-django
exec djangosocial-django python -m manage check "$@"
}
compose() {
$DOCKER_COMPOSE "$@"
}
djshell() {
_requires djangosocial-django
exec djangosocial-django python -m manage shell "$@"
}
makemigrations() {
_requires djangosocial-django
exec djangosocial-django python -m manage makemigrations "$@"
}
migrate() {
_requires djangosocial-django
exec djangosocial-django python -m manage migrate "$@"
}
pip-compile() {
_requires djangosocial-django
exec djangosocial-django pip-compile --generate-hashes "$@"
}
pip-upgrade() {
_requires djangosocial-django
exec djangosocial-django pip-compile --generate-hashes -U "$@"
}
shell() {
_requires djangosocial-django
exec djangosocial-django /bin/bash
}
start() {
$DOCKER_COMPOSE up "$@"
}
stop() {
$DOCKER_COMPOSE down "$@"
}
exec() {
$DOCKER_COMPOSE exec -e COLUMNS -e LINES "$@"
}
_usage() {
cat <<USAGE
Convenience wrapper around docker-compose.
Usage:
${BOLD}build${NORMAL}
Builds all the images (or the ones specified) for running
${BOLD}check${NORMAL}
Validate Django settings
${BOLD}compose${NORMAL}
Minimal wrapper around docker-compose, just ensures the correct config files are loaded.
${BOLD}djshell${NORMAL}
Opens a Django shell
${BOLD}exec${NORMAL} [<arg>]
Execute a command in a container
${BOLD}makemigrations${NORMAL} [<arg>]
Create a new Django migration, using the given args
${BOLD}migrate${NORMAL} [<arg>]
Apply any unapplied Django migrations
${BOLD}pip-compile${NORMAL} [<arg>]
This will re-compile the python requirements from the current requirements.in file
This is good to do if you add a new requirement, but don't want to upgrade any others when compiling requirements.txt
https://github.com/jazzband/pip-tools#pip-tools--pip-compile--pip-sync
${BOLD}pip-upgrade${NORMAL}
This will re-compile the python requirements from the current requirements.in file while also including the upgrade flag.
Therefore requirements.txt will be generated with newer versions of packages which aren't pinned
${BOLD}shell${NORMAL}
Opens a bash terminal in djangosocial-django
${BOLD}start${NORMAL} [<arg>]
Start the django server (and dependent services)
You can pass "-d" for running detached.
${BOLD}stop${NORMAL} [<arg>]
Stop the django server (and dependent services)
USAGE
}
if [ "$1" == "" ]; then
_usage;
fi
$*