-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp
More file actions
181 lines (164 loc) · 5.3 KB
/
app
File metadata and controls
181 lines (164 loc) · 5.3 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
# Build all of the images or the specified one
backend_seed () {
docker-compose exec flask_backend python manage.py seed
}
# Build all of the images or the specified one
build () {
docker-compose build "${@:1}"
}
# Generate a wildcard certificate
cert_generate () {
sudo rm -Rf server/certs/flask-redis.test.*
docker-compose run --rm nginx_server sh -c "cd /etc/nginx/certs && touch openssl.cnf && cat /etc/ssl/openssl.cnf > openssl.cnf && echo \"\" >> openssl.cnf && echo \"[ SAN ]\" >> openssl.cnf && echo \"subjectAltName=DNS.1:flask-redis.test,DNS.2:*.flask-redis.test\" >> openssl.cnf && openssl req -x509 -sha256 -nodes -newkey rsa:4096 -keyout flask-redis.test.key -out flask-redis.test.crt -days 3650 -subj \"/CN=*.flask-redis.test\" -config openssl.cnf -extensions SAN && rm openssl.cnf"
}
# Install the certificate
cert_install () {
if [[ "$OSTYPE" == "darwin"* ]]; then
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain server/certs/flask-redis.test.crt
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
sudo rm -r /usr/local/share/ca-certificates/flask-redis.test.crt
sudo ln -s "$(pwd)/server/certs/flask-redis.test.crt" /usr/local/share/ca-certificates/flask-redis.test.crt
sudo update-ca-certificates --fresh
# FOR WSL - ADD THIS TO YOUR LOCAL WINDOWS TRUSTED CERTS
# https://www.thewindowsclub.com/manage-trusted-root-certificates-windows
cp "$(pwd)/server/certs/flask-redis.test.crt" /mnt/c/TEMP/
echo "ADD THE CERT TO THE WINDOWS LOCAL TRUSTED CERTS IF YOU ARE USING WSL"
else
echo "Could not install the certificate on the host machine, please do it manually"
fi
}
# Remove the entire Docker environment
destroy () {
read -p "This will delete containers, volumes and images. Are you sure? [y/N]: " -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit; fi
docker-compose down -v --rmi all --remove-orphans
}
# Stop and destroy all containers
down () {
docker-compose down "${@:1}"
}
# Stop and destroy all containers
fresh () {
docker-compose down && docker-compose up --build -d
}
# Display and tail the logs
logs () {
docker-compose logs -f "${@:1}"
}
# Restart the containers
restart () {
stop && up
}
run () {
docker-compose run "${@:1}"
}
# Stop the containers
stop () {
docker-compose stop
}
# Create and start the containers and volumes
up () {
docker-compose up -d
}
# Run a Yarn command
yarn () {
docker-compose run --rm nuxt_frontend yarn "${@:1}"
}
#######################################
# MENU
#######################################
case "$1" in
backend)
case "$2" in
seed)
backend_seed
;;
*)
cat << EOF
Certificate management commands.
Usage:
seira cert <command>
Available commands:
seed ...................................... Seed the database
EOF
;;
esac
;;
build)
build "${@:2}"
;;
cert)
case "$2" in
generate)
cert_generate
;;
install)
cert_install
;;
*)
cat << EOF
Certificate management commands.
Usage:
seira cert <command>
Available commands:
generate .................................. Generate a new certificate
install ................................... Install the certificate
dhparam ................................... PROD STUFF
EOF
;;
esac
;;
destroy)
destroy
;;
down)
down "${@:2}"
;;
fresh)
fresh
;;
restart)
restart
;;
run)
run "${@:2}"
;;
logs)
logs "${@:2}"
;;
stop)
stop
;;
up)
up
;;
yarn)
yarn "${@:2}"
;;
*)
cat << EOF
Command line interface for the Docker-based web development environment seira.
Usage:
seira <command> [options] [arguments]
Available commands:
backend ................................... Manage the backend application
seed .................................. Seed the database
build [image] ............................. Build all of the images or the specified one
cert ...................................... Certificate management commands
generate .............................. Generate a new certificate
install ............................... Install the certificate
destroy ................................... Remove the entire Docker environment
down [-v] ................................. Stop and destroy all containers
Options:
-v .................... Destroy the volumes as well
logs [container] .......................... Display and tail the logs of all containers or the specified one's
restart ................................... Restart the containers
start ..................................... Start the containers
stop ...................................... Stop the containers
up ........................................ Build and start the containers
yarn ...................................... Run an Yarn command
EOF
exit 1
;;
esac