-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint
128 lines (96 loc) · 3.6 KB
/
docker-entrypoint
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
#!/bin/sh
SERVER_PORT=${SERVER_PORT:-5000}
SERVER_NAME=${SERVER_NAME:-localhost}
SERVER_SAN=${SERVER_SAN:-""}
SERVER_HTTPS=${SERVER_HTTPS:-""}
SERVER_HTTPS_INCLUDE=${SERVER_HTTPS_INCLUDE:-/etc/nginx/includes/default.https.conf}
SERVER_HTTPS_FNAME=${SERVER_HTTPS_FNAME:-site}
SERVER_WATCH_CRT=${SERVER_WATCH_CRT:-""}
SERVER_LOG=${SERVER_LOG:-""}
SERVER_ROOT=${SERVER_ROOT:-""}
SERVER_INDEX=${SERVER_INDEX:-""}
SERVER_LOCATION=${SERVER_LOCATION:-""}
SERVER_TRYFILES=${SERVER_TRYFILES:-""}
SERVER_TRYFILES_INCLUDE=${SERVER_TRYFILES_INCLUDE:-""}
SERVER_TRYFILES_PATH=${SERVER_TRYFILES_PATH:-"/"}
SERVER_TRYFILES_OTHER=${SERVER_TRYFILES_OTHER:-""}
SERVER_PHP=${SERVER_PHP:-""}
SERVER_PHP_INCLUDE=${SERVER_PHP_INCLUDE:-/etc/nginx/includes/default.php_fastcgi.conf}
SERVER_FAVICON=${SERVER_FAVICON:-0}
SERVER_ROBOTS=${SERVER_ROBOTS:-0}
SERVER_HT=${SERVER_HT:-0}
SERVER_REDIRECT=${SERVER_REDIRECT:-""}
SERVER_YAML=${SERVER_YAML:-""}
function __init(){
local out=${1:?Error}
if [[ -n "${SERVER_YAML}" ]]; then
set -- \
--yaml "${SERVER_YAML}"
else
set -- print \
-p "${SERVER_PORT}" \
-n "${SERVER_NAME}"
if [[ -n "${SERVER_SAN}" ]]; then
set -- "${@}" \
--san "${SERVER_SAN}"
fi
if [[ -n "${SERVER_HTTPS}" ]]; then
SERVER_WATCH_CRT=${SERVER_HTTPS}/${SERVER_HTTPS_FNAME}.crt
set -- "${@}" \
--https path="${SERVER_HTTPS}",include="${SERVER_HTTPS_INCLUDE}",filename="${SERVER_HTTPS_FNAME}"
fi
if [[ -n "${SERVER_LOG}" ]]; then
set -- "${@}" \
--log "${SERVER_LOG}"
fi
if [[ -n "${SERVER_ROOT}" ]]; then
set -- "${@}" \
--root "${SERVER_ROOT}"
fi
if [[ -n "${SERVER_INDEX}" ]]; then
set -- "${@}" \
--index "${SERVER_INDEX}"
fi
if [[ -n "${SERVER_LOCATION}" ]]; then
set -- "${@}" \
--location "${SERVER_LOCATION}"
fi
if [[ -n "${SERVER_TRYFILES}" ]]; then
set -- "${@}" \
--location path="${SERVER_TRYFILES_PATH}",type=try_files,value="${SERVER_TRYFILES}",include="${SERVER_TRYFILES_INCLUDE}",other="${SERVER_TRYFILES_OTHER}"
fi
if [[ -n "${SERVER_PHP}" ]]; then
set -- "${@}" \
--location path="~ \.php\$",type=fastcgi_pass,value="${SERVER_PHP}",include="${SERVER_PHP_INCLUDE}"
fi
if [[ -n "${SERVER_PHP}" || -n "${SERVER_TRYFILES}" ]]; then
SERVER_FAVICON=1
SERVER_ROBOTS=1
SERVER_HT=1
fi
if [[ $SERVER_FAVICON == 1 || $SERVER_FAVICON == true ]]; then
set -- "${@}" \
--location path=/favicon.ico,type=access_log,value=off,other="log_not_found off"
fi
if [[ $SERVER_ROBOTS == 1 || $SERVER_ROBOTS == true ]]; then
set -- "${@}" \
--location path=/robots.txt,type=access_log,value=off,other="log_not_found off"
fi
if [[ $SERVER_HT == 1 || $SERVER_HT == true ]]; then
set -- "${@}" \
--location path="~ /\.ht",type=deny,value=all
fi
if [[ -n "${SERVER_REDIRECT}" ]]; then
set -- "${@}" \
--redirect "value=${SERVER_REDIRECT}"
fi
fi
camarero "${@}" > ${out}
unset out
return 0
}
__init /etc/nginx/conf.d/default.conf
if [[ -n "${SERVER_WATCH_CRT}" ]]; then
sleep 10 && certwatch ${SERVER_WATCH_CRT} &
fi
exec "${@}"