Skip to content

Commit c00701b

Browse files
authored
Merge pull request #23 from danielsuguimoto/php84
adding php 8.4
2 parents a5b8bb6 + cc27b92 commit c00701b

File tree

14 files changed

+455
-1
lines changed

14 files changed

+455
-1
lines changed

.github/workflows/ci-cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
version: ['8.0-swoole', '8.1-swoole', '8.2-swoole', '8.3-swoole']
19+
version: ['8.0-swoole', '8.1-swoole', '8.2-swoole', '8.3-swoole', '8.4-swoole']
2020
type: ['', '-prod']
2121

2222
steps:

8.4-swoole-nginx-prod/Dockerfile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
FROM debian AS cert
2+
3+
WORKDIR /kool/ssl
4+
5+
RUN apt-get update && \
6+
apt-get install -y openssl && \
7+
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && \
8+
openssl rsa -passin pass:x -in server.pass.key -out _.localhost.key && \
9+
rm server.pass.key && \
10+
openssl req -new -key _.localhost.key -out server.csr \
11+
-subj "/C=XX/ST=XX/L=XX/O=Kool-Local/OU=Localhost/CN=*.localhost" && \
12+
openssl x509 -req -days 365 -in server.csr -signkey _.localhost.key -out _.localhost.crt && \
13+
openssl x509 -in _.localhost.crt -out _.localhost.pem
14+
15+
FROM kooldev/php:8.4-swoole-prod
16+
17+
ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
18+
NGINX_LISTEN=80 \
19+
NGINX_HTTPS=false \
20+
NGINX_LISTEN_HTTPS=443 \
21+
NGINX_HTTPS_CERT=/kool/ssl/_.localhost.pem \
22+
NGINX_HTTPS_CERT_KEY=/kool/ssl/_.localhost.key \
23+
NGINX_ROOT=/app/public \
24+
NGINX_INDEX=index.php \
25+
NGINX_CLIENT_MAX_BODY_SIZE=25M \
26+
NGINX_PHP_FPM=unix:/run/php-fpm.sock \
27+
NGINX_FASTCGI_READ_TIMEOUT=60s \
28+
NGINX_FASTCGI_BUFFERS='8 8k' \
29+
NGINX_FASTCGI_BUFFER_SIZE='16k' \
30+
NGINX_ENTRYPOINT_WORKER_PROCESSES_AUTOTUNE=true
31+
32+
RUN curl -L https://github.com/ochinchina/supervisord/releases/download/v0.6.3/supervisord_static_0.6.3_linux_amd64 -o /usr/local/bin/supervisord \
33+
&& chmod +x /usr/local/bin/supervisord \
34+
&& apk add --no-cache nginx \
35+
&& chown -R kool:kool /var/lib/nginx \
36+
&& chmod 770 /var/lib/nginx/tmp \
37+
&& ln -sf /dev/stdout /var/log/nginx/access.log \
38+
&& ln -sf /dev/stderr /var/log/nginx/error.log \
39+
# add h5bp/server-configs-nginx
40+
&& mkdir -p /etc/nginx/conf.d \
41+
&& mkdir /etc/nginx/h5bp \
42+
&& cd /etc/nginx/h5bp \
43+
&& wget https://github.com/h5bp/server-configs-nginx/archive/refs/tags/3.3.0.tar.gz -O h5bp.tgz \
44+
&& tar xzvf h5bp.tgz \
45+
&& rm -f h5bp.tgz \
46+
&& mv server-configs-nginx-*/h5bp/* . \
47+
&& mv server-configs-nginx-*/nginx.conf /etc/nginx/nginx.conf \
48+
&& sed -i "s|^user .*|user\ kool kool;|g" /etc/nginx/nginx.conf \
49+
&& mv server-configs-nginx-*/mime.types /etc/nginx/mime.types \
50+
&& rm -rf server-configs-nginx-* \
51+
&& curl -L https://raw.githubusercontent.com/nginxinc/docker-nginx/master/entrypoint/30-tune-worker-processes.sh -o /kool/30-tune-worker-processes.sh \
52+
&& chmod +x /kool/30-tune-worker-processes.sh
53+
54+
COPY supervisor.conf /kool/supervisor.conf
55+
COPY default.tmpl /kool/default.tmpl
56+
COPY entrypoint /kool/entrypoint
57+
COPY --from=cert /kool/ssl /kool/ssl
58+
RUN chmod +x /kool/entrypoint
59+
60+
EXPOSE 80
61+
62+
CMD [ "supervisord", "-c", "/kool/supervisor.conf" ]

8.4-swoole-nginx-prod/default.tmpl

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
map $http_upgrade $connection_upgrade {
2+
default upgrade;
3+
'' close;
4+
}
5+
6+
server {
7+
listen {{ .Env.NGINX_LISTEN }} default_server;
8+
server_name _;
9+
{{ if isTrue .Env.NGINX_HTTPS }}
10+
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
11+
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
12+
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
13+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
14+
ssl_ciphers HIGH:!aNULL:!MD5;
15+
{{ end }}
16+
root {{ .Env.NGINX_ROOT }};
17+
index {{ .Env.NGINX_INDEX }};
18+
charset utf-8;
19+
20+
location = /favicon.ico { log_not_found off; access_log off; }
21+
location = /robots.txt { log_not_found off; access_log off; }
22+
23+
client_max_body_size {{ .Env.NGINX_CLIENT_MAX_BODY_SIZE }};
24+
25+
error_page 404 /index.php;
26+
27+
location /index.php {
28+
try_files /not_exists @octane;
29+
}
30+
31+
location / {
32+
try_files $uri $uri/ @octane;
33+
34+
add_header X-Served-By kool.dev;
35+
}
36+
37+
location @octane {
38+
set $suffix "";
39+
40+
if ($uri = /index.php) {
41+
set $suffix ?$query_string;
42+
}
43+
44+
proxy_http_version 1.1;
45+
proxy_set_header Host $http_host;
46+
proxy_set_header Scheme $scheme;
47+
proxy_set_header SERVER_PORT $server_port;
48+
proxy_set_header REMOTE_ADDR $remote_addr;
49+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
50+
proxy_set_header Upgrade $http_upgrade;
51+
proxy_set_header Connection $connection_upgrade;
52+
53+
proxy_pass http://127.0.0.1:8000$suffix;
54+
}
55+
56+
location ~ /\.ht {
57+
deny all;
58+
}
59+
60+
# good practices
61+
add_header X-Frame-Options "SAMEORIGIN";
62+
63+
# basic H5BP suggestions
64+
include h5bp/internet_explorer/x-ua-compatible.conf;
65+
include h5bp/security/referrer-policy.conf;
66+
include h5bp/security/x-content-type-options.conf;
67+
include h5bp/security/x-xss-protection.conf;
68+
69+
# performance enhancements (mostly for caching static data)
70+
include h5bp/web_performance/cache-file-descriptors.conf;
71+
include h5bp/web_performance/pre-compressed_content_gzip.conf;
72+
}

8.4-swoole-nginx-prod/entrypoint

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
set -e
3+
4+
5+
# Run as current user
6+
CURRENT_USER=${ASUSER:-${UID:-0}}
7+
8+
if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then
9+
usermod -u $CURRENT_USER kool
10+
fi
11+
12+
dockerize -template /kool/kool.tmpl:/usr/local/etc/php/conf.d/kool.ini -template /kool/zz-docker.tmpl:/usr/local/etc/php-fpm.d/zz-docker.conf -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf
13+
14+
/kool/30-tune-worker-processes.sh
15+
16+
# Run entrypoint if provided
17+
if [ ! -z "$ENTRYPOINT" ] && [ -f "$ENTRYPOINT" ]; then
18+
bash $ENTRYPOINT
19+
fi
20+
21+
if [ "$1" = "sh" ] || [ "$1" = "bash" ] || [ "$1" = "php-fpm" ] || [ "$1" = "nginx" ] || [ "$1" = "supervisord" ]; then
22+
exec "$@"
23+
else
24+
exec su-exec kool "$@"
25+
fi
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[program:nginx]
2+
depends_on = octane
3+
command = nginx -g "daemon off;"
4+
autorestart = true
5+
stopasgroup = true
6+
stderr_logfile = /dev/stderr
7+
stdout_logfile = /dev/stdout
8+
9+
[program:octane]
10+
command = su-exec kool php artisan octane:start
11+
autorestart = true
12+
stopasgroup = true
13+
stderr_logfile = /dev/stderr
14+
stdout_logfile = /dev/stdout

8.4-swoole-nginx/Dockerfile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
FROM debian AS cert
2+
3+
WORKDIR /kool/ssl
4+
5+
RUN apt-get update && \
6+
apt-get install -y openssl && \
7+
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && \
8+
openssl rsa -passin pass:x -in server.pass.key -out _.localhost.key && \
9+
rm server.pass.key && \
10+
openssl req -new -key _.localhost.key -out server.csr \
11+
-subj "/C=XX/ST=XX/L=XX/O=Kool-Local/OU=Localhost/CN=*.localhost" && \
12+
openssl x509 -req -days 365 -in server.csr -signkey _.localhost.key -out _.localhost.crt && \
13+
openssl x509 -in _.localhost.crt -out _.localhost.pem
14+
15+
FROM kooldev/php:8.4-swoole
16+
17+
ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
18+
NGINX_LISTEN=80 \
19+
NGINX_HTTPS=false \
20+
NGINX_LISTEN_HTTPS=443 \
21+
NGINX_HTTPS_CERT=/kool/ssl/_.localhost.pem \
22+
NGINX_HTTPS_CERT_KEY=/kool/ssl/_.localhost.key \
23+
NGINX_ROOT=/app/public \
24+
NGINX_INDEX=index.php \
25+
NGINX_CLIENT_MAX_BODY_SIZE=25M \
26+
NGINX_PHP_FPM=unix:/run/php-fpm.sock \
27+
NGINX_FASTCGI_READ_TIMEOUT=60s \
28+
NGINX_FASTCGI_BUFFERS='8 8k' \
29+
NGINX_FASTCGI_BUFFER_SIZE='16k' \
30+
NGINX_ENTRYPOINT_WORKER_PROCESSES_AUTOTUNE=true
31+
32+
RUN curl -L https://github.com/ochinchina/supervisord/releases/download/v0.6.3/supervisord_static_0.6.3_linux_amd64 -o /usr/local/bin/supervisord \
33+
&& chmod +x /usr/local/bin/supervisord \
34+
&& apk add --no-cache nginx \
35+
&& chown -R kool:kool /var/lib/nginx \
36+
&& chmod 770 /var/lib/nginx/tmp \
37+
&& ln -sf /dev/stdout /var/log/nginx/access.log \
38+
&& ln -sf /dev/stderr /var/log/nginx/error.log \
39+
# add h5bp/server-configs-nginx
40+
&& mkdir -p /etc/nginx/conf.d \
41+
&& mkdir /etc/nginx/h5bp \
42+
&& cd /etc/nginx/h5bp \
43+
&& wget https://github.com/h5bp/server-configs-nginx/archive/refs/tags/3.3.0.tar.gz -O h5bp.tgz \
44+
&& tar xzvf h5bp.tgz \
45+
&& rm -f h5bp.tgz \
46+
&& mv server-configs-nginx-*/h5bp/* . \
47+
&& mv server-configs-nginx-*/nginx.conf /etc/nginx/nginx.conf \
48+
&& sed -i "s|^user .*|user\ kool kool;|g" /etc/nginx/nginx.conf \
49+
&& mv server-configs-nginx-*/mime.types /etc/nginx/mime.types \
50+
&& rm -rf server-configs-nginx-* \
51+
&& curl -L https://raw.githubusercontent.com/nginxinc/docker-nginx/master/entrypoint/30-tune-worker-processes.sh -o /kool/30-tune-worker-processes.sh \
52+
&& chmod +x /kool/30-tune-worker-processes.sh
53+
54+
COPY supervisor.conf /kool/supervisor.conf
55+
COPY default.tmpl /kool/default.tmpl
56+
COPY entrypoint /kool/entrypoint
57+
COPY --from=cert /kool/ssl /kool/ssl
58+
RUN chmod +x /kool/entrypoint
59+
60+
EXPOSE 80
61+
62+
CMD [ "supervisord", "-c", "/kool/supervisor.conf" ]

8.4-swoole-nginx/default.tmpl

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
map $http_upgrade $connection_upgrade {
2+
default upgrade;
3+
'' close;
4+
}
5+
6+
server {
7+
listen {{ .Env.NGINX_LISTEN }} default_server;
8+
server_name _;
9+
{{ if isTrue .Env.NGINX_HTTPS }}
10+
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
11+
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
12+
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
13+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
14+
ssl_ciphers HIGH:!aNULL:!MD5;
15+
{{ end }}
16+
root {{ .Env.NGINX_ROOT }};
17+
index {{ .Env.NGINX_INDEX }};
18+
charset utf-8;
19+
20+
location = /favicon.ico { log_not_found off; access_log off; }
21+
location = /robots.txt { log_not_found off; access_log off; }
22+
23+
client_max_body_size {{ .Env.NGINX_CLIENT_MAX_BODY_SIZE }};
24+
25+
error_page 404 /index.php;
26+
27+
location /index.php {
28+
try_files /not_exists @octane;
29+
}
30+
31+
location / {
32+
try_files $uri $uri/ @octane;
33+
34+
add_header X-Served-By kool.dev;
35+
}
36+
37+
location @octane {
38+
set $suffix "";
39+
40+
if ($uri = /index.php) {
41+
set $suffix ?$query_string;
42+
}
43+
44+
proxy_http_version 1.1;
45+
proxy_set_header Host $http_host;
46+
proxy_set_header Scheme $scheme;
47+
proxy_set_header SERVER_PORT $server_port;
48+
proxy_set_header REMOTE_ADDR $remote_addr;
49+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
50+
proxy_set_header Upgrade $http_upgrade;
51+
proxy_set_header Connection $connection_upgrade;
52+
53+
proxy_pass http://127.0.0.1:8000$suffix;
54+
}
55+
56+
location ~ /\.ht {
57+
deny all;
58+
}
59+
60+
# good practices
61+
add_header X-Frame-Options "SAMEORIGIN";
62+
63+
# basic H5BP suggestions
64+
include h5bp/internet_explorer/x-ua-compatible.conf;
65+
include h5bp/security/referrer-policy.conf;
66+
include h5bp/security/x-content-type-options.conf;
67+
include h5bp/security/x-xss-protection.conf;
68+
69+
# performance enhancements (mostly for caching static data)
70+
include h5bp/web_performance/cache-file-descriptors.conf;
71+
include h5bp/web_performance/pre-compressed_content_gzip.conf;
72+
}

8.4-swoole-nginx/entrypoint

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ "$ENABLE_XDEBUG" == "true" ]; then
5+
docker-php-ext-enable xdebug >> /dev/null 2>&1
6+
7+
if [ $? != "0" ]; then
8+
echo "[ERROR] An error happened enabling xdebug"
9+
10+
exit 1
11+
fi
12+
fi
13+
14+
# Run as current user
15+
CURRENT_USER=${ASUSER:-${UID:-0}}
16+
17+
if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then
18+
usermod -u $CURRENT_USER kool
19+
fi
20+
21+
dockerize -template /kool/kool.tmpl:/usr/local/etc/php/conf.d/kool.ini -template /kool/zz-docker.tmpl:/usr/local/etc/php-fpm.d/zz-docker.conf -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf
22+
23+
/kool/30-tune-worker-processes.sh
24+
25+
# Run entrypoint if provided
26+
if [ ! -z "$ENTRYPOINT" ] && [ -f "$ENTRYPOINT" ]; then
27+
bash $ENTRYPOINT
28+
fi
29+
30+
if [ "$1" = "sh" ] || [ "$1" = "bash" ] || [ "$1" = "php-fpm" ] || [ "$1" = "nginx" ] || [ "$1" = "supervisord" ]; then
31+
exec "$@"
32+
else
33+
exec su-exec kool "$@"
34+
fi

8.4-swoole-nginx/supervisor.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[program:nginx]
2+
depends_on = octane
3+
command = nginx -g "daemon off;"
4+
autorestart = true
5+
stopasgroup = true
6+
stderr_logfile = /dev/stderr
7+
stdout_logfile = /dev/stdout
8+
9+
[program:octane]
10+
command = su-exec kool php artisan octane:start --watch
11+
autorestart = true
12+
stopasgroup = true
13+
stderr_logfile = /dev/stderr
14+
stdout_logfile = /dev/stdout

8.4-swoole-prod/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM kooldev/php:8.4-prod
2+
3+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
4+
5+
RUN install-php-extensions swoole

0 commit comments

Comments
 (0)