-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnginx-php-fpm-template.yaml
332 lines (307 loc) · 12 KB
/
nginx-php-fpm-template.yaml
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
apiVersion: v1
kind: Template
metadata:
name: nginx-php-fpm
parameters:
- name: APP_NAME
value: "nginx-php-fpm"
required: true
- name: NGINX_IMAGE
description: "Image for nginx- (and init-) container"
value: "nginx:stable"
required: true
- name: PHP_FPM_IMAGE
description: "Source image for php-fpm build"
value: "php:7.2-fpm"
required: true
- name: WEBROOT_SIZE
value: "512Mi"
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
metadata:
name: ${APP_NAME}
labels:
app: ${APP_NAME}
spec:
replicas: 1
selector:
app: ${APP_NAME}
strategy:
type: Rolling
template:
metadata:
labels:
app: ${APP_NAME}
name: ${APP_NAME}
spec:
initContainers:
- name: ${APP_NAME}-init-container
image: ${NGINX_IMAGE}
command: ['sh', '-c', 'mkdir -p /var/www/html']
volumeMounts:
- mountPath: /var/www
name: webroot
containers:
- image: ${NGINX_IMAGE}
imagePullPolicy: Always
name: nginx
ports:
- name: http
containerPort: 8080
protocol: TCP
volumeMounts:
- mountPath: /etc/nginx
name: nginx-config
- mountPath: /var/cache/nginx
name: nginx-cache
- mountPath: /var/www
name: webroot
restartPolicy: Always
- image: php-fpm
imagePullPolicy: Always
name: php-fpm
env:
- name: HOME
value: /var/www
restartPolicy: Always
volumeMounts:
- mountPath: /var/www
name: webroot
volumes:
- name: nginx-config
configMap:
name: ${APP_NAME}-nginx-config
- name: nginx-cache
emptyDir: {}
- name: webroot
persistentVolumeClaim:
claimName: ${APP_NAME}-webroot
triggers:
- imageChangeParams:
automatic: true
containerNames:
- php-fpm
from:
kind: ImageStreamTag
name: ${APP_NAME}-php-fpm:latest
type: ImageChange
- type: ConfigChange
- apiVersion: v1
kind: BuildConfig
metadata:
labels:
app: ${APP_NAME}
build: ${APP_NAME}-php-fpm-build
name: ${APP_NAME}-php-fpm-build
spec:
output:
to:
kind: ImageStreamTag
name: ${APP_NAME}-php-fpm:latest
source:
dockerfile: |
FROM ${PHP_FPM_IMAGE}
RUN apt-get update \
&& apt-get install -y \
git \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libxml2-dev \
--no-install-recommends \
&& rm -r /var/lib/apt/lists/* \
&& docker-php-ext-install -j$(nproc) mbstring pdo_mysql json dom fileinfo zip \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
type: Dockerfile
strategy:
dockerStrategy:
from:
kind: DockerImage
name: ${PHP_FPM_IMAGE}
type: Docker
- apiVersion: v1
data:
mime.types: |2
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/svg+xml svg svgz;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/webp webp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
application/font-woff woff;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.oasis.opendocument.graphics odg;
application/vnd.oasis.opendocument.presentation odp;
application/vnd.oasis.opendocument.spreadsheet ods;
application/vnd.oasis.opendocument.text odt;
application/vnd.openxmlformats-officedocument.presentationml.presentation
pptx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
xlsx;
application/vnd.openxmlformats-officedocument.wordprocessingml.document
docx;
application/vnd.wap.wmlc wmlc;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}
nginx.conf: |-
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 8080 default_server;
root /var/www/html;
server_name _;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_pass localhost:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REDIRECT_STATUS 200;
}
}
}
kind: ConfigMap
metadata:
name: ${APP_NAME}-nginx-config
labels:
app: ${APP_NAME}
- apiVersion: v1
kind: Service
metadata:
name: ${APP_NAME}
labels:
app: ${APP_NAME}
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
name: ${APP_NAME}
type: ClusterIP
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${APP_NAME}-webroot
labels:
app: ${APP_NAME}
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: ${WEBROOT_SIZE}
- apiVersion: v1
kind: ImageStream
metadata:
labels:
app: ${APP_NAME}
build: ${APP_NAME}-php-fpm
name: ${APP_NAME}-php-fpm