-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
85cc6e4
commit 84341da
Showing
7 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters