-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdo.sh
More file actions
executable file
·163 lines (112 loc) · 3.17 KB
/
do.sh
File metadata and controls
executable file
·163 lines (112 loc) · 3.17 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/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
}
network() {
docker network create djangocmsnet
}
build() {
$DOCKER_COMPOSE build --force-rm \
"${@:1}"
}
check() {
_requires database_default
exec -w /app web django-admin check "$@"
}
compose() {
$DOCKER_COMPOSE "$@"
}
djshell() {
_requires database_default
exec -w /app web django-admin shell "$@"
}
makemigrations() {
_requires web
exec -w /app web django-admin makemigrations "$@"
}
migrate() {
_requires web
exec -w /app web django-admin migrate "$@"
}
pip-compile() {
_requires web
exec -w /app web pip-compile "$@"
}
pip-upgrade() {
_requires web
exec -w /app web pip-compile -U "$@"
}
shell() {
_requires web
exec -w /app web /bin/bash
}
showmigrations() {
_requires web
exec -w /app web django-admin showmigrations "$@"
}
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}bounce${NORMAL}
Tear down, rebuild and stand up all Docker containers (handy when you switch branches)
${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 web
${BOLD}showmigrations${NORMAL} [<arg>]
Show all relevant Django migrations, optionally scoped by the given args
${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
$*