-
Notifications
You must be signed in to change notification settings - Fork 3
/
Bockerfile.nginx
145 lines (117 loc) · 3.44 KB
/
Bockerfile.nginx
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
#!/bin/bash
# Purpose: Bocker library to generate Dockerfile for nginx image
# Author : Anh K. Huynh
# Date : 2015 May 19th
__NGINX_DIR="$(dirname ${BASH_SOURCE[0]:-.})"
ed_reuse $__NGINX_DIR/Bockerfile.supervisor
ed_env --later WWW_UID 10005
ed_copy --later etc/nginx/ /etc/nginx/
ed_expose 80
ed_ship --later \
ed_nginx_generate_config \
ed_nginx_daemonize
ed_bocker() {
ed_group \
ed_nginx_env \
ed_nginx_install_packages \
ed_nginx_download_source \
ed_nginx_hook_before_build \
ed_nginx_build \
ed_nginx_clean_up \
ed_nginx_hook_after_build \
ed_nginx_create_generator
}
########################################################################
ed_nginx_env() {
export NGINX_VERSION=1.10.1
export NGINX_CHECKSUM=9c5d4e06d309bbe2efa41f09dd53912e3c3d3a75
}
# Allow arbitary custom in another layer
ed_nginx_hook_before_build() {
:
}
ed_nginx_hook_after_build() {
:
}
ed_nginx_install_packages() {
ed_apt_install \
gcc libc6-dev make libpcre3-dev git nginx libssl-dev
}
ed_nginx_download_source() {
mkdir -pv /usr/src/build/modules/
cd /usr/src/build/
# Download all necessary files
curl -Lso- https://github.com/openresty/echo-nginx-module/archive/v0.59.tar.gz \
| tar -xzf - -C /usr/src/build/modules/
curl -Lso- https://github.com/openresty/headers-more-nginx-module/archive/v0.30.tar.gz \
| tar -xzf - -C /usr/src/build/modules/
curl -Lso /usr/src/build/nginx.tar.gz \
http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
echo "$NGINX_CHECKSUM *nginx.tar.gz" \
| sha1sum -c -
tar -xzf nginx.tar.gz -C /usr/src/build/
}
ed_nginx_clean_up() {
cd /
rm -rf /etc/nginx/ /usr/src/build/
ed_apt_purge gcc libc6-dev make libpcre3-dev git libssl-dev
}
ed_nginx_create_generator() {
ed_supervisor_generator ed_nginx_generate_config
}
ed_nginx_build() {
_NGINX_NAME="nginx-${NGINX_VERSION}"
_NGINX_FLAGS="
${_NGINX_FLAGS:-}
--prefix=/usr/
--conf-path=/etc/nginx/nginx.conf
--http-log-path=/var/log/nginx/acces.log
--error-log-path=/var/log/nginx/error.log
--lock-path=/var/lock/nginx.lock
--pid-path=/run/nginx.pid
--http-client-body-temp-path=/var/lib/nginx/body
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi
--http-proxy-temp-path=/var/lib/nginx/proxy
--http-scgi-temp-path=/var/lib/nginx/scgi
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi
--with-pcre
--with-http_ssl_module
--with-http_stub_status_module
--with-http_realip_module
--with-http_gzip_static_module
--with-http_sub_module
"
_NONSTANDARD_MODULES=""
_D_BUILD="/usr/src/build/"
_NONSTANDARD_MODULES="$( \
find $_D_BUILD/modules/ \
-mindepth 1 -maxdepth 1 -type d \
| while read _d; do \
echo -en " --add-module=$_d"; \
done)"
cd $_D_BUILD/$_NGINX_NAME
sed -i \
-e 's# bgcolor=\\"white\\"##g' \
-e 's#<center><h1>##g' \
-e 's#</h1></center>##g' \
-e '/NGINX_VER/d' \
-e '/>nginx</d' \
./src/http/ngx_http_special_response.c
sh configure \
$_NGINX_FLAGS \
$_NONSTANDARD_MODULES
make
make install
}
ed_nginx_daemonize() {
/usr/sbin/nginx -t -c /etc/nginx/nginx.conf || exit 1
exec /usr/sbin/nginx -c /etc/nginx/nginx.conf
}
ed_nginx_generate_config() {
chown -R www-data:www-data /var/lib/nginx
ed_supervisor_config_template \
--name "nginx" \
--command "/bocker.sh ed_nginx_daemonize" \
--dir "/" \
--user "root"
}