Skip to content

Commit 7f56e72

Browse files
committed
Tons of Improvements
1 parent a837d90 commit 7f56e72

32 files changed

Lines changed: 681 additions & 109 deletions

.github/workflows/docker.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,26 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
version: [ 7.4-fpm-alpine, 7.3-fpm-alpine, 7.2-fpm-alpine, 7.1-fpm-alpine ]
10+
version: [ 7.1, 7.2, 7.3, 7.4 ]
1111

1212
steps:
1313
- name: Checkout code
1414
uses: actions/checkout@master
1515

1616
- name: Build image
17-
run: docker build --pull -t kooldev/wordpress:${{ matrix.version }} ${{ matrix.version }}
18-
19-
- name: Test docker images default command
2017
run: |
21-
docker run -d --name cicdwp-${{ matrix.version }} kooldev/wordpress:${{ matrix.version }}
22-
docker inspect cicdwp-${{ matrix.version }} --format='{{.State.ExitCode}}'
23-
if [ $? -eq 0 ]; then
24-
docker stop cicdwp-${{ matrix.version }}
25-
fi
26-
18+
docker build --pull -t kooldev/wordpress:${{ matrix.version }} ${{ matrix.version }}
19+
docker build -t kooldev/wordpress:${{ matrix.version }}-nginx ${{ matrix.version }}-nginx
20+
2721
- name: Test docker images PHP executable
28-
run: docker run kooldev/wordpress:${{ matrix.version }} php -v
22+
run: |
23+
docker run kooldev/wordpress:${{ matrix.version }} php -v
24+
docker run kooldev/wordpress:${{ matrix.version }}-nginx php -v
2925
3026
- name: Test docker images wordpress code
31-
run: docker run kooldev/wordpress:${{ matrix.version }} php /usr/src/wordpress/index.php
27+
run: |
28+
docker run kooldev/wordpress:${{ matrix.version }} php /usr/src/wordpress/index.php
29+
docker run kooldev/wordpress:${{ matrix.version }}-nginx php /usr/src/wordpress/index.php
3230
3331
- name: Push to Hub
3432
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
@@ -38,3 +36,4 @@ jobs:
3836
run: |
3937
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
4038
docker push kooldev/wordpress:${{ matrix.version }}
39+
docker push kooldev/wordpress:${{ matrix.version }}-nginx

7.1-fpm-alpine/kool.ini

Lines changed: 0 additions & 20 deletions
This file was deleted.

7.1-nginx/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM kooldev/wordpress:7.1
2+
3+
ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
4+
NGINX_LISTEN=80 \
5+
NGINX_ROOT=/var/www/html \
6+
NGINX_CLIENT_MAX_BODY_SIZE=25M \
7+
NGINX_PHP_FPM=unix:/run/php-fpm.sock \
8+
NGINX_FASTCGI_READ_TIMEOUT=60s
9+
10+
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 \
11+
&& chmod +x /usr/local/bin/supervisord \
12+
&& apk add --no-cache nginx \
13+
&& sed -i "s|^listen\ \=.*|listen\ \= $PHP_FPM_LISTEN|g" /usr/local/etc/php-fpm.d/zz-docker.conf \
14+
&& echo "listen.owner = kool" >> /usr/local/etc/php-fpm.d/zz-docker.conf \
15+
&& echo "listen.group = kool" >> /usr/local/etc/php-fpm.d/zz-docker.conf \
16+
&& echo "listen.mode = 0666" >> /usr/local/etc/php-fpm.d/zz-docker.conf \
17+
&& sed -i "s|^user .*|user\ kool;|g" /etc/nginx/nginx.conf
18+
19+
COPY supervisor.conf /kool/supervisor.conf
20+
COPY default.tmpl /kool/default.tmpl
21+
22+
EXPOSE 80
23+
24+
ENTRYPOINT [ "dockerize", "-template", "/kool/kool.tmpl:/usr/local/etc/php/conf.d/kool.ini", "-template", "/kool/default.tmpl:/etc/nginx/conf.d/default.conf", "docker-entrypoint.sh" ]
25+
CMD [ "supervisord", "-c", "/kool/supervisor.conf" ]

7.1-nginx/default.tmpl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
server {
2+
listen {{ .Env.NGINX_LISTEN }} default_server;
3+
server_name _;
4+
root {{ .Env.NGINX_ROOT }};
5+
index index.php;
6+
charset utf-8;
7+
8+
location = /favicon.ico { log_not_found off; access_log off; }
9+
location = /robots.txt { log_not_found off; access_log off; }
10+
11+
client_max_body_size {{ .Env.NGINX_CLIENT_MAX_BODY_SIZE }};
12+
13+
error_page 404 /index.php;
14+
15+
location / {
16+
try_files $uri $uri/ /index.php?$query_string;
17+
18+
add_header X-Served-By kool.dev;
19+
}
20+
21+
location ~ \.php$ {
22+
fastcgi_pass {{ .Env.NGINX_PHP_FPM }};
23+
fastcgi_read_timeout {{ .Env.NGINX_FASTCGI_READ_TIMEOUT }};
24+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
25+
include fastcgi_params;
26+
}
27+
28+
location ~ /\.ht {
29+
deny all;
30+
}
31+
}

7.1-nginx/supervisor.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[program:nginx]
2+
depends_on = php-fpm
3+
command = nginx -g "pid /run/nginx.pid; daemon off;"
4+
stopasgroup = true
5+
stderr_logfile = /dev/stderr
6+
stdout_logfile = /dev/stdout
7+
8+
[program:php-fpm]
9+
command = php-fpm
10+
stopasgroup = true
11+
stderr_logfile = /dev/stderr
12+
stdout_logfile = /dev/stdout
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
FROM wordpress:php7.1-fpm-alpine
22

33
ENV PHP_MEMORY_LIMIT=256M \
4+
PHP_MAX_INPUT_VARS=1000 \
45
PHP_UPLOAD_MAX_FILESIZE=50M \
56
PHP_POST_MAX_SIZE=50M \
67
PHP_MAX_EXECUTION_TIME=30
78

89
RUN adduser -D -u 1337 kool \
10+
&& addgroup kool www-data \
911
# dockerize
1012
&& curl -L https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-alpine-linux-amd64-v0.6.1.tar.gz | tar xz \
1113
&& mv dockerize /usr/local/bin/dockerize \
@@ -14,6 +16,7 @@ RUN adduser -D -u 1337 kool \
1416
&& pecl install redis \
1517
&& docker-php-ext-enable redis \
1618
&& cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini \
19+
&& sed -i "s/user\ \=.*/user\ \= kool/g" /usr/local/etc/php-fpm.d/www.conf \
1720
# cleanup
1821
&& apk del .build-deps \
1922
&& rm -rf /var/cache/apk/* /tmp/*

7.1/kool.ini

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[PHP]
2+
3+
; Maximum amount of memory a script may consume
4+
; http://php.net/memory-limit
5+
memory_limit = {{ .Env.PHP_MEMORY_LIMIT }}
6+
7+
; Fix maximum variables per input
8+
max_input_vars = {{ .Env.PHP_MAX_INPUT_VARS }}
9+
10+
; Maximum allowed size for uploaded files.
11+
; http://php.net/upload-max-filesize
12+
upload_max_filesize = {{ .Env.PHP_UPLOAD_MAX_FILESIZE }}
13+
14+
; Maximum size of POST data that PHP will accept.
15+
; Its value may be 0 to disable the limit. It is ignored if POST data reading
16+
; is disabled through enable_post_data_reading.
17+
; http://php.net/post-max-size
18+
post_max_size = {{ .Env.PHP_POST_MAX_SIZE }}
19+
20+
; Maximum execution time of each script, in seconds
21+
; http://php.net/max-execution-time
22+
; Note: This directive is hardcoded to 0 for the CLI SAPI
23+
max_execution_time = {{ .Env.PHP_MAX_EXECUTION_TIME }}
24+
25+
[opcache]
26+
27+
; Determines if Zend OPCache is enabled
28+
opcache.enable=1
29+
30+
; The OPcache shared memory storage size.
31+
opcache.memory_consumption=512
32+
33+
; The amount of memory for interned strings in Mbytes.
34+
opcache.interned_strings_buffer=64
35+
36+
; The maximum number of keys (scripts) in the OPcache hash table.
37+
; Only numbers between 200 and 1000000 are allowed.
38+
opcache.max_accelerated_files=30000
39+
40+
; When disabled, you must reset the OPcache manually or restart the
41+
; webserver for changes to the filesystem to take effect.
42+
opcache.validate_timestamps=0
43+
44+
; If disabled, all PHPDoc comments are dropped from the code to reduce the
45+
; size of the optimized code.
46+
opcache.save_comments=1

7.2-fpm-alpine/kool.ini

Lines changed: 0 additions & 20 deletions
This file was deleted.

7.2-nginx/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM kooldev/wordpress:7.2
2+
3+
ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
4+
NGINX_LISTEN=80 \
5+
NGINX_ROOT=/var/www/html \
6+
NGINX_CLIENT_MAX_BODY_SIZE=25M \
7+
NGINX_PHP_FPM=unix:/run/php-fpm.sock \
8+
NGINX_FASTCGI_READ_TIMEOUT=60s
9+
10+
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 \
11+
&& chmod +x /usr/local/bin/supervisord \
12+
&& apk add --no-cache nginx \
13+
&& sed -i "s|^listen\ \=.*|listen\ \= $PHP_FPM_LISTEN|g" /usr/local/etc/php-fpm.d/zz-docker.conf \
14+
&& echo "listen.owner = kool" >> /usr/local/etc/php-fpm.d/zz-docker.conf \
15+
&& echo "listen.group = kool" >> /usr/local/etc/php-fpm.d/zz-docker.conf \
16+
&& echo "listen.mode = 0666" >> /usr/local/etc/php-fpm.d/zz-docker.conf \
17+
&& sed -i "s|^user .*|user\ kool;|g" /etc/nginx/nginx.conf
18+
19+
COPY supervisor.conf /kool/supervisor.conf
20+
COPY default.tmpl /kool/default.tmpl
21+
22+
EXPOSE 80
23+
24+
ENTRYPOINT [ "dockerize", "-template", "/kool/kool.tmpl:/usr/local/etc/php/conf.d/kool.ini", "-template", "/kool/default.tmpl:/etc/nginx/conf.d/default.conf", "docker-entrypoint.sh" ]
25+
CMD [ "supervisord", "-c", "/kool/supervisor.conf" ]

7.2-nginx/default.tmpl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
server {
2+
listen {{ .Env.NGINX_LISTEN }} default_server;
3+
server_name _;
4+
root {{ .Env.NGINX_ROOT }};
5+
index index.php;
6+
charset utf-8;
7+
8+
location = /favicon.ico { log_not_found off; access_log off; }
9+
location = /robots.txt { log_not_found off; access_log off; }
10+
11+
client_max_body_size {{ .Env.NGINX_CLIENT_MAX_BODY_SIZE }};
12+
13+
error_page 404 /index.php;
14+
15+
location / {
16+
try_files $uri $uri/ /index.php?$query_string;
17+
18+
add_header X-Served-By kool.dev;
19+
}
20+
21+
location ~ \.php$ {
22+
fastcgi_pass {{ .Env.NGINX_PHP_FPM }};
23+
fastcgi_read_timeout {{ .Env.NGINX_FASTCGI_READ_TIMEOUT }};
24+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
25+
include fastcgi_params;
26+
}
27+
28+
location ~ /\.ht {
29+
deny all;
30+
}
31+
}

0 commit comments

Comments
 (0)