Skip to content

Commit

Permalink
added 8.2-node flavour
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriciojs committed Oct 24, 2023
1 parent 85cc6e4 commit 84341da
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 0 deletions.
83 changes: 83 additions & 0 deletions 8.2-node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
FROM php:8.2-fpm-alpine

ENV ASUSER= \
UID= \
COMPOSER_ALLOW_SUPERUSER=1 \
COMPOSER_MEMORY_LIMIT=-1 \
ENABLE_XDEBUG=false \
PHP_DATE_TIMEZONE=UTC \
PHP_MEMORY_LIMIT=256M \
PHP_MAX_INPUT_VARS=1000 \
PHP_UPLOAD_MAX_FILESIZE=25M \
PHP_POST_MAX_SIZE=25M \
PHP_MAX_EXECUTION_TIME=30 \
PHP_FPM_LISTEN=9000 \
PHP_FPM_MAX_CHILDREN=10 \
PHP_FPM_REQUEST_TERMINATE_TIMEOUT=60 \
ENTRYPOINT=entrypoint.php.sh

WORKDIR /app

RUN adduser -D -u 1337 kool \
&& addgroup kool www-data \
# dockerize
&& curl -L https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-alpine-linux-amd64-v0.6.1.tar.gz | tar xz \
&& mv dockerize /usr/local/bin/dockerize \
# deps
&& apk --no-cache add su-exec bash sed git openssh-client icu shadow procps \
freetype libpng libjpeg-turbo libzip-dev ghostscript imagemagick \
jpegoptim optipng pngquant gifsicle libldap \
libpq less \
# build-deps
&& apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
freetype-dev libpng-dev libjpeg-turbo-dev \
icu-dev libedit-dev libxml2-dev \
imagemagick-dev openldap-dev oniguruma-dev \
postgresql-dev \
linux-headers \
# php-ext
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS" \
&& docker-php-ext-install -j$(nproc) \
bcmath \
calendar \
exif \
gd \
intl \
ldap \
mbstring \
pcntl \
pdo \
pdo_mysql \
pdo_pgsql \
soap \
xml \
zip \
sockets \
mysqli \
&& pecl install imagick redis \
&& pecl install xdebug \
&& pecl install pcov && docker-php-ext-enable pcov \
&& docker-php-ext-enable imagick \
&& docker-php-ext-enable redis \
&& cp "/usr/local/etc/php/php.ini-development" "/usr/local/etc/php/php.ini" \
# composer
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer1 \
# symlink composer2 for BC
&& ln -s /usr/local/bin/composer /usr/local/bin/composer2 \
# cleanup
&& apk del .build-deps \
&& rm -rf /var/cache/apk/* /tmp/*

RUN apk add --update --no-cache npm

COPY kool.ini /kool/kool.tmpl
COPY zz-docker.conf /kool/zz-docker.tmpl
COPY entrypoint /kool/entrypoint
RUN chmod +x /kool/entrypoint

EXPOSE 9000

ENTRYPOINT [ "/kool/entrypoint" ]
CMD [ "php-fpm" ]
33 changes: 33 additions & 0 deletions 8.2-node/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh
set -e

if [ "$ENABLE_XDEBUG" == "true" ]; then
docker-php-ext-enable xdebug >> /dev/null 2>&1

if [ $? != "0" ]; then
echo "[ERROR] An error happened enabling xdebug"

exit 1
fi
fi

# Run as current user
CURRENT_USER=${ASUSER:-${UID:-0}}

if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then
usermod -u $CURRENT_USER kool
fi

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


# Run entrypoint if provided
if [ ! -z "$ENTRYPOINT" ] && [ -f "$ENTRYPOINT" ]; then
bash $ENTRYPOINT
fi

if [ "$1" = "sh" ] || [ "$1" = "bash" ] || [ "$1" = "php-fpm" ] ; then
exec "$@"
else
exec su-exec kool "$@"
fi
29 changes: 29 additions & 0 deletions 8.2-node/kool.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[PHP]

; Maximum amount of memory a script may consume
; http://php.net/memory-limit
memory_limit = {{ .Env.PHP_MEMORY_LIMIT }}

; Fix maximum variables per input
max_input_vars = {{ .Env.PHP_MAX_INPUT_VARS }}

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = {{ .Env.PHP_UPLOAD_MAX_FILESIZE }}

; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = {{ .Env.PHP_POST_MAX_SIZE }}

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = {{ .Env.PHP_MAX_EXECUTION_TIME }}

; Default timezone used by all date/time functions.
; https://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = {{ .Env.PHP_DATE_TIMEZONE }}


48 changes: 48 additions & 0 deletions 8.2-node/zz-docker.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[global]
daemonize = no

[www]
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = kool
group = kool

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = {{ .Env.PHP_FPM_LISTEN }}

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions. The owner
; and group can be specified either by name or by their numeric IDs.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = kool
listen.group = kool

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = {{ .Env.PHP_FPM_MAX_CHILDREN }}

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_terminate_timeout = {{ .Env.PHP_FPM_REQUEST_TERMINATE_TIMEOUT }}
28 changes: 28 additions & 0 deletions fwd-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,34 @@
}
]
},
{
"name": "8.2-node",
"data": {
"from": "php:8.2-fpm-alpine",
"with_node": true,
"prod": false,
"nginx": false,
"version": "8.2"
},
"files": [
{
"name": "Dockerfile",
"path": "template/Dockerfile"
},
{
"name": "entrypoint",
"path": "template/entrypoint"
},
{
"name": "kool.ini",
"path": "template/kool-ini"
},
{
"name": "zz-docker.conf",
"path": "template/zz-docker-conf"
}
]
},
{
"name": "8.2-nginx",
"data": {
Expand Down
1 change: 1 addition & 0 deletions kool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ scripts:
build-8.2:
- docker build --pull -t kooldev/php:8.2 8.2
- docker build --pull -t kooldev/php:8.2-prod 8.2-prod
- docker build --pull -t kooldev/php:8.2-node 8.2-node
- docker build -t kooldev/php:8.2-nginx 8.2-nginx
- docker build -t kooldev/php:8.2-nginx-prod 8.2-nginx-prod
build:
Expand Down
4 changes: 4 additions & 0 deletions template/Dockerfile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
&& apk del .build-deps \
&& rm -rf /var/cache/apk/* /tmp/*

@if ($with_node ?? false)
RUN apk add --update --no-cache npm

@endif
COPY kool.ini /kool/kool.tmpl
COPY zz-docker.conf /kool/zz-docker.tmpl
COPY entrypoint /kool/entrypoint
Expand Down

0 comments on commit 84341da

Please sign in to comment.