Skip to content

Commit 3931673

Browse files
committed
feat: add PHP configuration and Dockerfile for CSlant development environment
1 parent 2f10f26 commit 3931673

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed

php74/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
ARG PHP_VERSION=7.4
2+
3+
FROM php:${PHP_VERSION}-fpm-alpine
4+
LABEL maintainer="Tan Nguyen <tannp@cslant.com>"
5+
LABEL authors="cslant"
6+
LABEL description="PHP image for CSlant development"
7+
8+
## Make php ini
9+
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
10+
11+
## Install composer
12+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
13+
&& php composer-setup.php \
14+
&& mv composer.phar /usr/local/bin/composer
15+
16+
## Config user
17+
ARG USER_ID=1000
18+
ENV USER_ID=${USER_ID}
19+
ARG GROUP_ID=1000
20+
ENV GROUP_ID=${GROUP_ID}
21+
22+
# ensure www-data user exists
23+
RUN set -eu; \
24+
addgroup -g ${USER_ID} csdev; \
25+
adduser -D -u ${USER_ID} -G csdev csdev
26+
27+
ADD cslant.php.ini "$PHP_INI_DIR/conf.d/cslant.ini"
28+
ADD cslant.pool.conf /usr/local/etc/php-fpm.d/www.conf
29+
30+
# Default workdir
31+
WORKDIR /var/dev
32+
33+
## Install Ext
34+
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
35+
RUN install-php-extensions soap pcntl bcmath gd exif sockets zip xdebug redis intl pdo_pgsql pgsql pdo_mysql mysqli imap
36+
37+
USER csdev
38+
39+
CMD ["php-fpm"]

php74/cslant.php.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
date.timezone=Asia/Ho_Chi_Minh
2+
display_errors=Off
3+
log_errors=On
4+
5+
memory_limit = 256M
6+
upload_max_filesize = 20M
7+
post_max_size = 20M
8+
max_execution_time=600
9+
default_socket_timeout=3600
10+
request_terminate_timeout=600

php74/cslant.pool.conf

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
; Start a new pool named 'www'.
2+
; the variable $pool can be used in any directive and will be replaced by the
3+
; pool name ('www' here)
4+
[www]
5+
6+
; Unix user/group of processes
7+
; Note: The user is mandatory. If the group is not set, the default user's group
8+
; will be used.
9+
user = csdev
10+
group = csdev
11+
12+
; The address on which to accept FastCGI requests.
13+
; Valid syntaxes are:
14+
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
15+
; a specific port;
16+
; 'port' - to listen on a TCP socket to all addresses on a
17+
; specific port;
18+
; '/path/to/unix/socket' - to listen on a unix socket.
19+
; Note: This value is mandatory.
20+
listen = 0.0.0.0:9000
21+
22+
; Choose how the process manager will control the number of child processes.
23+
; Possible Values:
24+
; static - a fixed number (pm.max_children) of child processes;
25+
; dynamic - the number of child processes are set dynamically based on the
26+
; following directives. With this process management, there will be
27+
; always at least 1 children.
28+
; pm.max_children - the maximum number of children that can
29+
; be alive at the same time.
30+
; pm.start_servers - the number of children created on startup.
31+
; pm.min_spare_servers - the minimum number of children in 'idle'
32+
; state (waiting to process). If the number
33+
; of 'idle' processes is less than this
34+
; number then some children will be created.
35+
; pm.max_spare_servers - the maximum number of children in 'idle'
36+
; state (waiting to process). If the number
37+
; of 'idle' processes is greater than this
38+
; number then some children will be killed.
39+
; ondemand - no children are created at startup. Children will be forked when
40+
; new requests will connect. The following parameter are used:
41+
; pm.max_children - the maximum number of children that
42+
; can be alive at the same time.
43+
; pm.process_idle_timeout - The number of seconds after which
44+
; an idle process will be killed.
45+
; Note: This value is mandatory.
46+
pm = dynamic
47+
48+
; The number of child processes to be created when pm is set to 'static' and the
49+
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
50+
; This value sets the limit on the number of simultaneous requests that will be
51+
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
52+
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
53+
; CGI. The below defaults are based on a server without much resources. Don't
54+
; forget to tweak pm.* to fit your needs.
55+
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
56+
; Note: This value is mandatory.
57+
pm.max_children = 20
58+
59+
; The number of child processes created on startup.
60+
; Note: Used only when pm is set to 'dynamic'
61+
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
62+
pm.start_servers = 2
63+
64+
; The desired minimum number of idle server processes.
65+
; Note: Used only when pm is set to 'dynamic'
66+
; Note: Mandatory when pm is set to 'dynamic'
67+
pm.min_spare_servers = 1
68+
69+
; The desired maximum number of idle server processes.
70+
; Note: Used only when pm is set to 'dynamic'
71+
; Note: Mandatory when pm is set to 'dynamic'
72+
pm.max_spare_servers = 3
73+
74+
catch_workers_output = yes

0 commit comments

Comments
 (0)