Skip to content

Commit f19e074

Browse files
authored
Merge pull request #70 from diogofm7/master
Add PHP 8.2
2 parents 548352d + 9acecbe commit f19e074

19 files changed

Lines changed: 761 additions & 0 deletions

8.2-nginx-prod/Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM kooldev/php:8.2-prod
2+
3+
ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
4+
NGINX_LISTEN=80 \
5+
NGINX_ROOT=/app/public \
6+
NGINX_INDEX=index.php \
7+
NGINX_CLIENT_MAX_BODY_SIZE=25M \
8+
NGINX_PHP_FPM=unix:/run/php-fpm.sock \
9+
NGINX_FASTCGI_READ_TIMEOUT=60s \
10+
NGINX_FASTCGI_BUFFERS='8 8k' \
11+
NGINX_FASTCGI_BUFFER_SIZE='16k'
12+
13+
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 \
14+
&& chmod +x /usr/local/bin/supervisord \
15+
&& apk add --no-cache nginx \
16+
&& chown -R kool:kool /var/lib/nginx \
17+
&& chmod 770 /var/lib/nginx/tmp \
18+
&& ln -sf /dev/stdout /var/log/nginx/access.log \
19+
&& ln -sf /dev/stderr /var/log/nginx/error.log \
20+
# add h5bp/server-configs-nginx
21+
&& mkdir -p /etc/nginx/conf.d \
22+
&& mkdir /etc/nginx/h5bp \
23+
&& cd /etc/nginx/h5bp \
24+
&& wget https://github.com/h5bp/server-configs-nginx/archive/refs/tags/3.3.0.tar.gz -O h5bp.tgz \
25+
&& tar xzvf h5bp.tgz \
26+
&& rm -f h5bp.tgz \
27+
&& mv server-configs-nginx-*/h5bp/* . \
28+
&& mv server-configs-nginx-*/nginx.conf /etc/nginx/nginx.conf \
29+
&& sed -i "s|^user .*|user\ kool kool;|g" /etc/nginx/nginx.conf \
30+
&& mv server-configs-nginx-*/mime.types /etc/nginx/mime.types \
31+
&& rm -rf server-configs-nginx-*
32+
33+
COPY supervisor.conf /kool/supervisor.conf
34+
COPY default.tmpl /kool/default.tmpl
35+
COPY entrypoint /kool/entrypoint
36+
RUN chmod +x /kool/entrypoint
37+
38+
EXPOSE 80
39+
40+
CMD [ "supervisord", "-c", "/kool/supervisor.conf" ]

8.2-nginx-prod/default.tmpl

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
server {
2+
listen {{ .Env.NGINX_LISTEN }} default_server;
3+
server_name _;
4+
root {{ .Env.NGINX_ROOT }};
5+
index {{ .Env.NGINX_INDEX }};
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/ /{{ .Env.NGINX_INDEX }}?$query_string;
17+
18+
add_header X-Served-By kool.dev;
19+
}
20+
21+
location ~ \.php$ {
22+
fastcgi_buffers {{ .Env.NGINX_FASTCGI_BUFFERS }};
23+
fastcgi_buffer_size {{ .Env.NGINX_FASTCGI_BUFFER_SIZE }};
24+
fastcgi_pass {{ .Env.NGINX_PHP_FPM }};
25+
fastcgi_read_timeout {{ .Env.NGINX_FASTCGI_READ_TIMEOUT }};
26+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
27+
include fastcgi_params;
28+
}
29+
30+
location ~ /\.ht {
31+
deny all;
32+
}
33+
34+
# good practices
35+
add_header X-Frame-Options "SAMEORIGIN";
36+
37+
# basic H5BP suggestions
38+
include h5bp/internet_explorer/x-ua-compatible.conf;
39+
include h5bp/security/referrer-policy.conf;
40+
include h5bp/security/x-content-type-options.conf;
41+
include h5bp/security/x-xss-protection.conf;
42+
43+
# performance enhancements (mostly for caching static data)
44+
include h5bp/web_performance/cache-file-descriptors.conf;
45+
include h5bp/web_performance/pre-compressed_content_gzip.conf;
46+
}

8.2-nginx-prod/entrypoint

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
# Run entrypoint if provided
15+
if [ ! -z "$ENTRYPOINT" ] && [ -f "$ENTRYPOINT" ]; then
16+
bash $ENTRYPOINT
17+
fi
18+
19+
if [ "$1" = "sh" ] || [ "$1" = "bash" ] || [ "$1" = "php-fpm" ] || [ "$1" = "nginx" ] || [ "$1" = "supervisord" ]; then
20+
exec "$@"
21+
else
22+
exec su-exec kool "$@"
23+
fi

8.2-nginx-prod/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 "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

8.2-nginx/Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM kooldev/php:8.2
2+
3+
ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
4+
NGINX_LISTEN=80 \
5+
NGINX_ROOT=/app/public \
6+
NGINX_INDEX=index.php \
7+
NGINX_CLIENT_MAX_BODY_SIZE=25M \
8+
NGINX_PHP_FPM=unix:/run/php-fpm.sock \
9+
NGINX_FASTCGI_READ_TIMEOUT=60s \
10+
NGINX_FASTCGI_BUFFERS='8 8k' \
11+
NGINX_FASTCGI_BUFFER_SIZE='16k'
12+
13+
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 \
14+
&& chmod +x /usr/local/bin/supervisord \
15+
&& apk add --no-cache nginx \
16+
&& chown -R kool:kool /var/lib/nginx \
17+
&& chmod 770 /var/lib/nginx/tmp \
18+
&& ln -sf /dev/stdout /var/log/nginx/access.log \
19+
&& ln -sf /dev/stderr /var/log/nginx/error.log \
20+
# add h5bp/server-configs-nginx
21+
&& mkdir -p /etc/nginx/conf.d \
22+
&& mkdir /etc/nginx/h5bp \
23+
&& cd /etc/nginx/h5bp \
24+
&& wget https://github.com/h5bp/server-configs-nginx/archive/refs/tags/3.3.0.tar.gz -O h5bp.tgz \
25+
&& tar xzvf h5bp.tgz \
26+
&& rm -f h5bp.tgz \
27+
&& mv server-configs-nginx-*/h5bp/* . \
28+
&& mv server-configs-nginx-*/nginx.conf /etc/nginx/nginx.conf \
29+
&& sed -i "s|^user .*|user\ kool kool;|g" /etc/nginx/nginx.conf \
30+
&& mv server-configs-nginx-*/mime.types /etc/nginx/mime.types \
31+
&& rm -rf server-configs-nginx-*
32+
33+
COPY supervisor.conf /kool/supervisor.conf
34+
COPY default.tmpl /kool/default.tmpl
35+
COPY entrypoint /kool/entrypoint
36+
RUN chmod +x /kool/entrypoint
37+
38+
EXPOSE 80
39+
40+
CMD [ "supervisord", "-c", "/kool/supervisor.conf" ]

8.2-nginx/default.tmpl

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
server {
2+
listen {{ .Env.NGINX_LISTEN }} default_server;
3+
server_name _;
4+
root {{ .Env.NGINX_ROOT }};
5+
index {{ .Env.NGINX_INDEX }};
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/ /{{ .Env.NGINX_INDEX }}?$query_string;
17+
18+
add_header X-Served-By kool.dev;
19+
}
20+
21+
location ~ \.php$ {
22+
fastcgi_buffers {{ .Env.NGINX_FASTCGI_BUFFERS }};
23+
fastcgi_buffer_size {{ .Env.NGINX_FASTCGI_BUFFER_SIZE }};
24+
fastcgi_pass {{ .Env.NGINX_PHP_FPM }};
25+
fastcgi_read_timeout {{ .Env.NGINX_FASTCGI_READ_TIMEOUT }};
26+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
27+
include fastcgi_params;
28+
}
29+
30+
location ~ /\.ht {
31+
deny all;
32+
}
33+
34+
# good practices
35+
add_header X-Frame-Options "SAMEORIGIN";
36+
37+
# basic H5BP suggestions
38+
include h5bp/internet_explorer/x-ua-compatible.conf;
39+
include h5bp/security/referrer-policy.conf;
40+
include h5bp/security/x-content-type-options.conf;
41+
include h5bp/security/x-xss-protection.conf;
42+
43+
# performance enhancements (mostly for caching static data)
44+
include h5bp/web_performance/cache-file-descriptors.conf;
45+
include h5bp/web_performance/pre-compressed_content_gzip.conf;
46+
}

8.2-nginx/entrypoint

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
# Run entrypoint if provided
24+
if [ ! -z "$ENTRYPOINT" ] && [ -f "$ENTRYPOINT" ]; then
25+
bash $ENTRYPOINT
26+
fi
27+
28+
if [ "$1" = "sh" ] || [ "$1" = "bash" ] || [ "$1" = "php-fpm" ] || [ "$1" = "nginx" ] || [ "$1" = "supervisord" ]; then
29+
exec "$@"
30+
else
31+
exec su-exec kool "$@"
32+
fi

8.2-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 "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

8.2-prod/Dockerfile

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
FROM php:8.2-fpm-alpine
2+
3+
ENV ASUSER= \
4+
UID= \
5+
COMPOSER_ALLOW_SUPERUSER=1 \
6+
COMPOSER_MEMORY_LIMIT=-1 \
7+
PHP_DATE_TIMEZONE=UTC \
8+
PHP_MEMORY_LIMIT=256M \
9+
PHP_MAX_INPUT_VARS=1000 \
10+
PHP_UPLOAD_MAX_FILESIZE=25M \
11+
PHP_POST_MAX_SIZE=25M \
12+
PHP_MAX_EXECUTION_TIME=30 \
13+
PHP_FPM_LISTEN=9000 \
14+
PHP_FPM_MAX_CHILDREN=10 \
15+
PHP_FPM_REQUEST_TERMINATE_TIMEOUT=60 \
16+
ENTRYPOINT=entrypoint.php.sh
17+
18+
WORKDIR /app
19+
20+
RUN adduser -D -u 1337 kool \
21+
&& addgroup kool www-data \
22+
# dockerize
23+
&& curl -L https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-alpine-linux-amd64-v0.6.1.tar.gz | tar xz \
24+
&& mv dockerize /usr/local/bin/dockerize \
25+
# deps
26+
&& apk --no-cache add su-exec bash sed git openssh-client icu shadow procps \
27+
freetype libpng libjpeg-turbo libzip-dev ghostscript imagemagick \
28+
jpegoptim optipng pngquant gifsicle libldap \
29+
libpq less \
30+
# build-deps
31+
&& apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
32+
freetype-dev libpng-dev libjpeg-turbo-dev \
33+
icu-dev libedit-dev libxml2-dev \
34+
imagemagick-dev openldap-dev oniguruma-dev \
35+
postgresql-dev \
36+
# php-ext
37+
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
38+
&& export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS" \
39+
&& docker-php-ext-install -j$(nproc) \
40+
bcmath \
41+
calendar \
42+
exif \
43+
gd \
44+
intl \
45+
ldap \
46+
mbstring \
47+
opcache \
48+
pcntl \
49+
pdo \
50+
pdo_mysql \
51+
pdo_pgsql \
52+
soap \
53+
xml \
54+
zip \
55+
sockets \
56+
mysqli \
57+
&& pecl install imagick redis \
58+
&& docker-php-ext-enable imagick \
59+
&& docker-php-ext-enable redis \
60+
&& cp "/usr/local/etc/php/php.ini-production" "/usr/local/etc/php/php.ini" \
61+
# composer
62+
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
63+
&& curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer1 \
64+
# symlink composer2 for BC
65+
&& ln -s /usr/local/bin/composer /usr/local/bin/composer2 \
66+
# cleanup
67+
&& apk del .build-deps \
68+
&& rm -rf /var/cache/apk/* /tmp/*
69+
70+
COPY kool.ini /kool/kool.tmpl
71+
COPY zz-docker.conf /kool/zz-docker.tmpl
72+
COPY entrypoint /kool/entrypoint
73+
RUN chmod +x /kool/entrypoint
74+
75+
EXPOSE 9000
76+
77+
ENTRYPOINT [ "/kool/entrypoint" ]
78+
CMD [ "php-fpm" ]

8.2-prod/entrypoint

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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
13+
14+
# Run entrypoint if provided
15+
if [ ! -z "$ENTRYPOINT" ] && [ -f "$ENTRYPOINT" ]; then
16+
bash $ENTRYPOINT
17+
fi
18+
19+
if [ "$1" = "sh" ] || [ "$1" = "bash" ] || [ "$1" = "php-fpm" ] ; then
20+
exec "$@"
21+
else
22+
exec su-exec kool "$@"
23+
fi

0 commit comments

Comments
 (0)