-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
106 lines (91 loc) · 2.39 KB
/
entrypoint.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
#!/bin/bash
if [ $1 == "uwsgi" ]; then
shift
cd /var/www && python3 manage.py migrate
uwsgi --uid www-data --gid www-data --plugins=python3 --chdir=/var/www --socket=0.0.0.0:9000 $@
elif [ $1 == "celery" ]; then
shift
/usr/local/bin/celery worker -B -A $@
elif [ $1 == "nginx" ]; then
cd /var/www && echo "yes" | python3 manage.py collectstatic
chown -R www-data. /var/www
cat >/etc/nginx/sites-available/default <<EOL
server {
listen 80;
root /var/www;
client_max_body_size 50M;
location / {
include uwsgi_params;
proxy_pass http://$_CGI:9000;
}
location /static {
alias /var/www/static;
}
location /cdn {
alias /var/www/uploads;
}
}
server {
listen 8080;
root /var/www/uploads;
client_max_body_size 50M;
location / {
add_header Access-Control-Allow-Origin "*";
alias /var/www/uploads/;
}
location /static {
add_header Access-Control-Allow-Origin "*";
alias /var/www/static;
}
}
EOL
# Nginx conf
cat >/etc/nginx/nginx.conf <<EOL
user www-data;
worker_processes auto;
pid /run/nginx.pid;
daemon off;
events {
worker_connections 1024;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
#tcp_nopush on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
gzip on;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
application/atom+xml
application/javascript
application/json
application/rss+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
text/plain
text/x-component;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
EOL
nginx
elif [ $1 == "bash" ]; then
bash
fi