Skip to content

Commit 07b6d29

Browse files
committed
7.4
1 parent 682e2ef commit 07b6d29

8 files changed

+416
-0
lines changed

7.4/Dockerfile

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
FROM alpine:3.13
2+
3+
LABEL Maintainer="chuoke"
4+
5+
# mirrors.aliyun.com
6+
# mirrors.tuna.tsinghua.edu.cn
7+
ARG ALPINE_APK_REPO=mirrors.aliyun.com
8+
ENV ALPINE_APK_REPO=${ALPINE_APK_REPO}
9+
10+
RUN if [ ${ALPINE_APK_REPO} ]; then \
11+
sed -i "s/dl-cdn.alpinelinux.org/${ALPINE_APK_REPO}/g" /etc/apk/repositories; \
12+
fi && \
13+
apk update \
14+
&& apk upgrade \
15+
&& apk add --no-cache openssl bash curl ca-certificates shadow
16+
17+
# 修改时区
18+
RUN apk add -U tzdata; \
19+
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime; \
20+
apk del tzdata
21+
22+
RUN apk update && \
23+
apk add --no-cache \
24+
php7 \
25+
php7-common \
26+
php7-fpm \
27+
# laravel 必须
28+
php7-bcmath \
29+
php7-ctype \
30+
php7-fileinfo \
31+
php7-json \
32+
php7-mbstring \
33+
php7-openssl \
34+
php7-pdo \
35+
php7-tokenizer \
36+
php7-xml \
37+
# 其它扩展需要
38+
php7-curl \
39+
php7-dom \
40+
php7-gd \
41+
php7-opcache \
42+
php7-simplexml \
43+
php7-xmlwriter \
44+
php7-posix \
45+
# 其它常用模块
46+
php7-zlib \
47+
php7-zip \
48+
php7-sodium \
49+
php7-phar \
50+
php7-exif \
51+
php7-iconv \
52+
php7-intl \
53+
php7-session \
54+
php7-xmlreader \
55+
php7-ftp \
56+
php7-sockets \
57+
php7-calendar \
58+
php7-mysqli \
59+
php7-pdo_mysql \
60+
php7-pdo_sqlite \
61+
php7-sqlite3 \
62+
php7-pcntl \
63+
php7-gettext \
64+
php7-imap \
65+
# pecl extensions
66+
php7-pecl-redis \
67+
php7-pecl-uuid \
68+
php7-pecl-xdebug \
69+
php7-pecl-apcu \
70+
php7-pecl-imagick
71+
72+
# Configure PHP-FPM
73+
# COPY php-fpm.conf /etc/php/php-fpm.d/www.conf
74+
COPY php-fpm.conf /etc/php7/php-fpm.d/www.conf
75+
COPY php.ini /etc/php/conf.d/custom.ini
76+
77+
RUN if [ ! -e "/usr/bin/php" ]; then \
78+
ln -s /usr/bin/php7 /usr/bin/php; \
79+
fi
80+
81+
# Install composer
82+
ENV COMPOSER_HOME /composer
83+
ENV PATH ./vendor/bin:/composer/vendor/bin:$PATH
84+
ENV COMPOSER_ALLOW_SUPERUSER 1
85+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
86+
php composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
87+
php -r "unlink('composer-setup.php');"
88+
89+
# Config Composer packagist repo
90+
ARG COMPOSER_REPO_PACKAGIST=https://mirrors.aliyun.com/composer/
91+
ENV COMPOSER_REPO_PACKAGIST=${COMPOSER_REPO_PACKAGIST}
92+
RUN if [ ${COMPOSER_REPO_PACKAGIST} ]; then \
93+
composer config -g repo.packagist composer ${COMPOSER_REPO_PACKAGIST} \
94+
;fi
95+
96+
# Install about nginx
97+
RUN apk --no-cache add nginx && \
98+
if [ -f '/etc/nginx/conf.d/default.conf' ]; then \
99+
rm /etc/nginx/conf.d/default.conf \
100+
;fi
101+
102+
# Configure nginx
103+
COPY nginx.conf /etc/nginx/nginx.conf
104+
105+
# Install supervisor
106+
RUN apk --no-cache add supervisor
107+
108+
# Configure supervisord
109+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
110+
111+
# Clean
112+
RUN rm /var/cache/apk/*
113+
114+
# ensure www-data user exists
115+
RUN set -x ; \
116+
addgroup -g 82 -S www-data ; \
117+
adduser -u 82 -D -S -G www-data www-data && exit 0 ; exit 1
118+
119+
ARG PUID=1000
120+
ENV PUID ${PUID}
121+
ARG PGID=1000
122+
ENV PGID ${PGID}
123+
124+
RUN groupmod -o -g ${PGID} www-data && \
125+
usermod -o -u ${PUID} -g www-data www-data
126+
127+
RUN groupmod -o -g ${PGID} nginx && \
128+
usermod -o -u ${PUID} -g nginx nginx
129+
130+
COPY start-container /usr/local/bin/start-container
131+
RUN chmod +x /usr/local/bin/start-container
132+
133+
# Setup document root
134+
RUN mkdir -p /var/www/
135+
RUN chown -R www-data:www-data /var/www/
136+
137+
# Add application
138+
WORKDIR /var/www/
139+
140+
# Expose the port nginx is reachable on
141+
EXPOSE 80 443
142+
143+
# Let supervisord start
144+
# CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
145+
ENTRYPOINT ["start-container"]

7.4/config/nginx-site.conf

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
server {
2+
3+
listen 80;
4+
# listen [::]:80;
5+
6+
# For https
7+
# listen 443 ssl;
8+
# listen [::]:443 ssl ipv6only=on;
9+
# ssl_certificate /etc/nginx/ssl/default.crt;
10+
# ssl_certificate_key /etc/nginx/ssl/default.key;
11+
12+
# server_name example.test;
13+
root /var/www/public;
14+
index index.php index.html index.htm;
15+
16+
location / {
17+
try_files $uri $uri/ /index.php$is_args$args;
18+
}
19+
20+
location ~ \.php$ {
21+
try_files $uri /index.php =404;
22+
# fastcgi_pass php-upstream;
23+
fastcgi_pass php-fpm:9000;
24+
fastcgi_index index.php;
25+
fastcgi_buffers 16 16k;
26+
fastcgi_buffer_size 32k;
27+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
28+
#fixes timeouts
29+
fastcgi_read_timeout 600;
30+
include fastcgi_params;
31+
}
32+
33+
location ~ /\.ht {
34+
deny all;
35+
}
36+
37+
location /.well-known/acme-challenge/ {
38+
root /var/www/letsencrypt/;
39+
log_not_found off;
40+
}
41+
42+
error_log /var/log/nginx/error.log;
43+
access_log /var/log/nginx/access.log;
44+
}
45+

7.4/config/supervisord.conf

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[program:php-fpm]
2+
command=php-fpm7 -F
3+
stdout_logfile=/dev/stdout
4+
stdout_logfile_maxbytes=0
5+
stderr_logfile=/dev/stderr
6+
stderr_logfile_maxbytes=0
7+
autorestart=true
8+
startretries=3
9+
10+
[program:laravel-scheduler]
11+
process_name=%(program_name)s_%(process_num)02d
12+
command=/bin/sh -c "while [ true ]; do (php /var/www/site/artisan schedule:run --verbose --no-interaction &); sleep 60; done"
13+
autostart=true
14+
autorestart=true
15+
numprocs=1
16+
user=www-data
17+
redirect_stderr=true
18+
19+
[program:laravel-worker]
20+
process_name=%(program_name)s_%(process_num)02d
21+
command=php /var/www/site/artisan queue:work --sleep=3 --tries=3 --max-time=3600
22+
autostart=true
23+
autorestart=true
24+
stopasgroup=true
25+
killasgroup=true
26+
user=www-data
27+
numprocs=4
28+
redirect_stderr=true
29+
stdout_logfile=/var/www/site/worker.log
30+
stopwaitsecs=3600
31+
32+
[program:nginx]
33+
command=nginx
34+
stdout_logfile=/dev/stdout
35+
stdout_logfile_maxbytes=0
36+
stderr_logfile=/dev/stderr
37+
stderr_logfile_maxbytes=0
38+
autorestart=true
39+
startretries=3

7.4/nginx.conf

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
user www-data;
2+
worker_processes 4;
3+
pid /run/nginx.pid;
4+
daemon off;
5+
6+
events {
7+
worker_connections 2048;
8+
multi_accept on;
9+
use epoll;
10+
}
11+
12+
http {
13+
server_tokens off;
14+
sendfile on;
15+
16+
tcp_nopush on;
17+
tcp_nodelay on;
18+
19+
keepalive_timeout 65;
20+
21+
types_hash_max_size 2048;
22+
client_max_body_size 50M;
23+
24+
include /etc/nginx/mime.types;
25+
default_type application/octet-stream;
26+
27+
# Define custom log format to include reponse times
28+
log_format main_timed '$remote_addr - $remote_user [$time_local] "$request" '
29+
'$status $body_bytes_sent "$http_referer" '
30+
'"$http_user_agent" "$http_x_forwarded_for" '
31+
'$request_time $upstream_response_time $pipe $upstream_cache_status';
32+
33+
access_log /dev/stdout main_timed;
34+
error_log /dev/stderr notice;
35+
36+
# Write temporary files to /tmp so they can be created as a non-privileged user
37+
client_body_temp_path /tmp/client_temp;
38+
proxy_temp_path /tmp/proxy_temp_path;
39+
fastcgi_temp_path /tmp/fastcgi_temp;
40+
uwsgi_temp_path /tmp/uwsgi_temp;
41+
scgi_temp_path /tmp/scgi_temp;
42+
43+
gzip on;
44+
gzip_proxied any;
45+
gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss;
46+
gzip_vary on;
47+
gzip_disable "msie6";
48+
49+
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
50+
# ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
51+
52+
open_file_cache off; # Disabled for issue 619
53+
charset UTF-8;
54+
55+
# server {
56+
# listen 80;
57+
# listen [::]:80;
58+
59+
# # For https
60+
# # listen 443 ssl;
61+
# # listen [::]:443 ssl ipv6only=on;
62+
# # ssl_certificate /etc/nginx/ssl/default.crt;
63+
# # ssl_certificate_key /etc/nginx/ssl/default.key;
64+
65+
# server_name localhost;
66+
# root /var/www/;
67+
# index index.php index.html index.htm;
68+
69+
# location ~ \.php$ {
70+
# try_files $uri /index.php =404;
71+
# # fastcgi_pass php-upstream;
72+
# # fastcgi_pass unix:/run/php/php-fpm7.sock;
73+
# fastcgi_pass 127.0.0.1:9000;
74+
# fastcgi_index index.php;
75+
# fastcgi_buffers 16 16k;
76+
# fastcgi_buffer_size 32k;
77+
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
78+
# #fixes timeouts
79+
# fastcgi_read_timeout 600;
80+
# include fastcgi_params;
81+
# }
82+
# }
83+
84+
# include /etc/nginx/conf.d/*.conf;
85+
include /etc/nginx/sites-available/*.conf;
86+
}

7.4/php-fpm.conf

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[global]
2+
; Log to stderr
3+
error_log = /dev/stderr
4+
5+
[www]
6+
user = www-data
7+
group = www-data
8+
9+
; The address on which to accept FastCGI requests.
10+
; Valid syntaxes are:
11+
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
12+
; a specific port;
13+
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
14+
; a specific port;
15+
; 'port' - to listen on a TCP socket to all addresses
16+
; (IPv6 and IPv4-mapped) on a specific port;
17+
; '/path/to/unix/socket' - to listen on a unix socket.
18+
; Note: This value is mandatory.
19+
; listen = unix:/run/php/php-fpm7.sock
20+
listen = 127.0.0.1:9000
21+
22+
23+
; Enable status page
24+
pm.status_path = /fpm-status
25+
26+
27+
; Ondemand process manager
28+
pm = ondemand
29+
30+
; The number of child processes to be created when pm is set to 'static' and the
31+
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
32+
; This value sets the limit on the number of simultaneous requests that will be
33+
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
34+
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
35+
; CGI. The below defaults are based on a server without much resources. Don't
36+
; forget to tweak pm.* to fit your needs.
37+
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
38+
; Note: This value is mandatory.
39+
pm.max_children = 100
40+
41+
; The number of seconds after which an idle process will be killed.
42+
; Note: Used only when pm is set to 'ondemand'
43+
; Default Value: 10s
44+
pm.process_idle_timeout = 10s;
45+
46+
; The number of requests each child process should execute before respawning.
47+
; This can be useful to work around memory leaks in 3rd party libraries. For
48+
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
49+
; Default Value: 0
50+
pm.max_requests = 1000
51+
52+
; Make sure the FPM workers can reach the environment variables for configuration
53+
clear_env = no
54+
55+
; Catch output from PHP
56+
catch_workers_output = yes
57+
58+
; Remove the 'child 10 said into stderr' prefix in the log and only show the actual message
59+
decorate_workers_output = no
60+
61+
; Enable ping page to use in healthcheck
62+
ping.path = /fpm-ping

7.4/php.ini

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Date]
2+
date.timezone="Asia/Shanghai"

0 commit comments

Comments
 (0)