Skip to content

Commit 72090bf

Browse files
authored
Merge pull request #6 from cslant/main-backup-20251125-090834
feat: add PHP configuration and Docker setup for CSlant development
2 parents f05662b + cdd4c0e commit 72090bf

File tree

3 files changed

+147
-0
lines changed

3 files changed

+147
-0
lines changed

php85/Dockerfile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
ARG PHP_VERSION=8.5
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 system packages and Git
34+
RUN apk add --no-cache git
35+
36+
## Install Ext
37+
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
38+
RUN install-php-extensions soap pcntl bcmath gd exif sockets zip xdebug redis intl pdo_pgsql pgsql pdo_mysql mysqli imagick curl fileinfo xml mbstring sodium bcmath
39+
40+
# Install WP-CLI
41+
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
42+
chmod +x wp-cli.phar && \
43+
mv wp-cli.phar /usr/local/bin/wp && \
44+
wp --allow-root cli version
45+
46+
# Create necessary directories and set permissions
47+
RUN mkdir -p /home/csdev/.wp-cli/cache && \
48+
chown -R csdev:csdev /home/csdev/.wp-cli && \
49+
chmod 777 /home/csdev/.wp-cli/cache
50+
51+
# Create necessary directories for WP-CLI
52+
RUN mkdir -p /home/csdev/.wp-cli/cache && \
53+
chown -R csdev:csdev /home/csdev/.wp-cli && \
54+
chmod 777 /home/csdev/.wp-cli/cache
55+
56+
# Switch to non-root user
57+
USER csdev
58+
59+
# Set WP-CLI configuration
60+
ENV WP_CLI_CACHE_DIR=/home/csdev/.wp-cli/cache
61+
62+
CMD ["php-fpm"]

php85/cslant.php.ini

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

php85/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)