Skip to content

Commit 84341da

Browse files
committed
added 8.2-node flavour
1 parent 85cc6e4 commit 84341da

7 files changed

Lines changed: 226 additions & 0 deletions

File tree

8.2-node/Dockerfile

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

8.2-node/entrypoint

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

8.2-node/kool.ini

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
; Default timezone used by all date/time functions.
26+
; https://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
27+
date.timezone = {{ .Env.PHP_DATE_TIMEZONE }}
28+
29+

8.2-node/zz-docker.conf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[global]
2+
daemonize = no
3+
4+
[www]
5+
; Unix user/group of processes
6+
; Note: The user is mandatory. If the group is not set, the default user's group
7+
; will be used.
8+
user = kool
9+
group = kool
10+
11+
; The address on which to accept FastCGI requests.
12+
; Valid syntaxes are:
13+
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
14+
; a specific port;
15+
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
16+
; a specific port;
17+
; 'port' - to listen on a TCP socket to all addresses
18+
; (IPv6 and IPv4-mapped) on a specific port;
19+
; '/path/to/unix/socket' - to listen on a unix socket.
20+
; Note: This value is mandatory.
21+
listen = {{ .Env.PHP_FPM_LISTEN }}
22+
23+
; Set permissions for unix socket, if one is used. In Linux, read/write
24+
; permissions must be set in order to allow connections from a web server. Many
25+
; BSD-derived systems allow connections regardless of permissions. The owner
26+
; and group can be specified either by name or by their numeric IDs.
27+
; Default Values: user and group are set as the running user
28+
; mode is set to 0660
29+
listen.owner = kool
30+
listen.group = kool
31+
32+
; The number of child processes to be created when pm is set to 'static' and the
33+
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
34+
; This value sets the limit on the number of simultaneous requests that will be
35+
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
36+
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
37+
; CGI. The below defaults are based on a server without much resources. Don't
38+
; forget to tweak pm.* to fit your needs.
39+
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
40+
; Note: This value is mandatory.
41+
pm.max_children = {{ .Env.PHP_FPM_MAX_CHILDREN }}
42+
43+
; The timeout for serving a single request after which the worker process will
44+
; be killed. This option should be used when the 'max_execution_time' ini option
45+
; does not stop script execution for some reason. A value of '0' means 'off'.
46+
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
47+
; Default Value: 0
48+
request_terminate_timeout = {{ .Env.PHP_FPM_REQUEST_TERMINATE_TIMEOUT }}

fwd-template.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,34 @@
271271
}
272272
]
273273
},
274+
{
275+
"name": "8.2-node",
276+
"data": {
277+
"from": "php:8.2-fpm-alpine",
278+
"with_node": true,
279+
"prod": false,
280+
"nginx": false,
281+
"version": "8.2"
282+
},
283+
"files": [
284+
{
285+
"name": "Dockerfile",
286+
"path": "template/Dockerfile"
287+
},
288+
{
289+
"name": "entrypoint",
290+
"path": "template/entrypoint"
291+
},
292+
{
293+
"name": "kool.ini",
294+
"path": "template/kool-ini"
295+
},
296+
{
297+
"name": "zz-docker.conf",
298+
"path": "template/zz-docker-conf"
299+
}
300+
]
301+
},
274302
{
275303
"name": "8.2-nginx",
276304
"data": {

kool.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ scripts:
1313
build-8.2:
1414
- docker build --pull -t kooldev/php:8.2 8.2
1515
- docker build --pull -t kooldev/php:8.2-prod 8.2-prod
16+
- docker build --pull -t kooldev/php:8.2-node 8.2-node
1617
- docker build -t kooldev/php:8.2-nginx 8.2-nginx
1718
- docker build -t kooldev/php:8.2-nginx-prod 8.2-nginx-prod
1819
build:

template/Dockerfile.blade.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@
8484
&& apk del .build-deps \
8585
&& rm -rf /var/cache/apk/* /tmp/*
8686

87+
@if ($with_node ?? false)
88+
RUN apk add --update --no-cache npm
89+
90+
@endif
8791
COPY kool.ini /kool/kool.tmpl
8892
COPY zz-docker.conf /kool/zz-docker.tmpl
8993
COPY entrypoint /kool/entrypoint

0 commit comments

Comments
 (0)