Skip to content

Commit 38ffede

Browse files
first commit
0 parents  commit 38ffede

19 files changed

+3453
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

BuildAndDeploy.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
# Used to build and deploy to minikube for local dev
3+
4+
# Openresty
5+
TIMESTAMP=`date "+%d-%m-%y-%H-%M-%S"`
6+
docker build -t lawrencedudley/k8s-openresty-php-openresty:$TIMESTAMP -f openresty/Dockerfile .
7+
docker push lawrencedudley/k8s-openresty-php-openresty:$TIMESTAMP
8+
9+
# PHP
10+
docker build --build-arg PHP_VERSION=7.3 --build-arg ATATUS_VERSION=1.8.0 -t lawrencedudley/k8s-openresty-php-php:$TIMESTAMP-7.3 -f php/Dockerfile .
11+
docker push lawrencedudley/k8s-openresty-php-php:$TIMESTAMP-7.3
12+
docker build --build-arg PHP_VERSION=7.4 --build-arg ATATUS_VERSION=1.8.0 -t lawrencedudley/k8s-openresty-php-php:$TIMESTAMP-7.3 -f php/Dockerfile .
13+
docker push lawrencedudley/k8s-openresty-php-php:$TIMESTAMP-7.4
14+
15+
# Copy yaml-template
16+
rm -f yaml-deploy/*
17+
cp yaml-templates/* yaml-deploy/
18+
19+
# Values
20+
sed -i '' -e "s#{{ OPENRESTYIMAGEHERE }}#lawrencedudley/k8s-openresty-php-openresty:$TIMESTAMP#g" yaml-deploy/deployment.yaml
21+
sed -i '' -e "s#{{ PHPIMAGEHERE }}#lawrencedudley/k8s-openresty-php-php:$TIMESTAMP-7.3#g" yaml-deploy/deployment.yaml
22+
23+
# Apply to Kubernetes
24+
kubectl apply -f yaml-deploy/deployment.yaml
25+
kubectl apply -f yaml-deploy/service.yaml

openresty/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM openresty/openresty:1.15.8.2-1-alpine
2+
3+
ADD /openresty/conf/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
4+
ADD /openresty/conf/default.conf /etc/nginx/conf.d/default.conf

openresty/conf/default.conf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
server {
2+
listen 80 default_server;
3+
4+
root /src-shared/public;
5+
6+
add_header Pod $hostname;
7+
8+
index index.php index.html index.htm;
9+
10+
server_name _;
11+
12+
location / {
13+
try_files $uri $uri/ /index.php?$query_string;
14+
}
15+
16+
# PHP files to PHP
17+
location ~ \.php$ {
18+
try_files $uri =404;
19+
include fastcgi_params;
20+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
21+
fastcgi_pass unix:/run/php.sock;
22+
fastcgi_param SERVER_NAME $http_host;
23+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
24+
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
25+
fastcgi_index index.php;
26+
fastcgi_read_timeout 600s;
27+
fastcgi_request_buffering off;
28+
fastcgi_param PHP_VALUE "atatus.enabled=on;";
29+
}
30+
31+
# Nginx Health Check Endpoint
32+
location ~ ^/(healthz)$ {
33+
content_by_lua_block {
34+
ngx.status = 200
35+
ngx.header['Content-Type'] = 'text/plain'
36+
ngx.say("Nginx OK")
37+
ngx.exit(ngx.OK)
38+
}
39+
access_log off;
40+
}
41+
42+
location ~ ^/(500)$ {
43+
content_by_lua_block {
44+
ngx.status = 500
45+
ngx.headers["Content-Type"] = "text/plain"
46+
ngx.exit(500)
47+
}
48+
}
49+
}

openresty/conf/nginx.conf

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
user nobody nobody;
2+
pid /run/nginx.pid;
3+
4+
worker_processes 1;
5+
6+
error_log /dev/stderr warn;
7+
8+
events {
9+
worker_connections 1024;
10+
}
11+
12+
http {
13+
14+
aio threads;
15+
16+
# Fix broken uploads
17+
client_body_temp_path /var/nginx-uploads 1;
18+
client_body_buffer_size 16k;
19+
client_body_in_file_only off;
20+
client_body_in_single_buffer off;
21+
22+
# Includes mapping of file name extensions to MIME types of responses
23+
# and defines the default type.
24+
include /usr/local/openresty/nginx/conf/mime.types;
25+
default_type application/octet-stream;
26+
27+
# Don't tell nginx version to clients.
28+
server_tokens off;
29+
30+
# Specifies the maximum accepted body size of a client request, as
31+
# indicated by the request header Content-Length. If the stated content
32+
# length is greater than this size, then the client receives the HTTP
33+
# error code 413. Set to 0 to disable.
34+
client_max_body_size 1024m;
35+
36+
# Timeout for keep-alive connections. Server will close connections after
37+
# this time.
38+
keepalive_timeout 120;
39+
keepalive_requests 20000;
40+
41+
42+
# Large cookies/header
43+
client_header_buffer_size 8k;
44+
large_client_header_buffers 8 128k;
45+
46+
# Sendfile copies data between one FD and other from within the kernel,
47+
# which is more efficient than read() + write().
48+
sendfile on;
49+
50+
# Don't buffer data-sends (disable Nagle algorithm).
51+
# Good for sending frequent small bursts of data in real time.
52+
tcp_nodelay on;
53+
54+
# Causes nginx to attempt to send its HTTP response head in one packet,
55+
# instead of using partial frames.
56+
tcp_nopush on;
57+
58+
gzip on;
59+
gzip_vary on;
60+
gzip_proxied any;
61+
gzip_comp_level 6;
62+
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;
63+
64+
# Enable checking the existence of precompressed files.
65+
gzip_static off;
66+
67+
log_format kubernetes $time_local ' From: ' $http_x_forwarded_for ' Request: ' $request_method ' ' $http_x_forwarded_proto '://' $host $request_uri ' Response: HTTP Code: ' $status ' Bytes Sent: ' $bytes_sent ' Time: ' $request_time;
68+
69+
# Sets the path, format, and configuration for a buffered log write.
70+
access_log /dev/stdout kubernetes;
71+
72+
# Includes virtual hosts configs.
73+
include /etc/nginx/conf.d/*.conf;
74+
75+
}

0 commit comments

Comments
 (0)