Skip to content

Commit 1cbb9c6

Browse files
committed
8.1
1 parent 9a9d255 commit 1cbb9c6

9 files changed

+491
-0
lines changed

8.1/Dockerfile

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
FROM alpine:edge
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+
# swoole 在 testing 库
11+
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories
12+
13+
RUN if [ ${ALPINE_APK_REPO} ]; then \
14+
sed -i "s/dl-cdn.alpinelinux.org/${ALPINE_APK_REPO}/g" /etc/apk/repositories; \
15+
fi
16+
17+
RUN apk update \
18+
&& apk upgrade \
19+
&& apk add --no-cache openssl bash curl ca-certificates shadow \
20+
nodejs py3-setuptools
21+
22+
## Install about PHP
23+
24+
RUN apk update && \
25+
apk add --no-cache \
26+
php81 \
27+
php81-common \
28+
php81-fpm \
29+
# Laravel Requirements
30+
php81-bcmath \
31+
php81-ctype \
32+
php81-fileinfo \
33+
php81-json \
34+
php81-mbstring \
35+
php81-openssl \
36+
php81-pdo \
37+
php81-tokenizer \
38+
php81-xml \
39+
# Base Requirements
40+
php81-curl \
41+
php81-dom \
42+
php81-gd \
43+
php81-opcache \
44+
php81-xmlwriter \
45+
php81-simplexml \
46+
php81-posix \
47+
php81-opcache \
48+
# Other Requirements
49+
php81-zlib \
50+
php81-zip \
51+
php81-sodium \
52+
php81-phar \
53+
php81-exif \
54+
php81-iconv \
55+
php81-intl \
56+
php81-session \
57+
php81-xmlreader \
58+
php81-ftp \
59+
php81-sockets \
60+
php81-calendar \
61+
php81-mysqli \
62+
php81-pdo_mysql \
63+
php81-pdo_sqlite \
64+
php81-sqlite3 \
65+
php81-pcntl \
66+
php81-gettext \
67+
php81-imap \
68+
# pecl extensions
69+
php81-pecl-apcu \
70+
php81-pecl-redis \
71+
php8-pecl-imagick \
72+
# php81-pecl-xdebug \ Can't coexist with Swoole,see Swoole's doc
73+
php81-pecl-swoole
74+
75+
# Configure PHP-FPM
76+
COPY php-fpm.conf /etc/php81/php-fpm.d/www.conf
77+
COPY php.ini /etc/php81/conf.d/custom.ini
78+
79+
RUN ln -s /usr/bin/php81 /usr/bin/php
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+
97+
# Install about nginx
98+
RUN apk --no-cache add nginx && \
99+
if [ -f '/etc/nginx/conf.d/default.conf' ]; then \
100+
rm /etc/nginx/conf.d/default.conf \
101+
;fi
102+
103+
# Configure nginx
104+
COPY nginx.conf /etc/nginx/nginx.conf
105+
106+
# Install supervisor
107+
RUN apk --no-cache add supervisor
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
142+
143+
# CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
144+
145+
ENTRYPOINT ["start-container"]

8.1/config/nginx-octane.conf

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# https://laravel.com/docs/8.x/octane#serving-your-application-via-nginx
2+
3+
map $http_upgrade $connection_upgrade {
4+
default upgrade;
5+
'' close;
6+
}
7+
8+
server {
9+
listen 80;
10+
listen [::]:80;
11+
server_name domain.com;
12+
server_tokens off;
13+
root /var/www/site/public;
14+
15+
index index.php;
16+
17+
charset utf-8;
18+
19+
location /index.php {
20+
try_files /not_exists @octane;
21+
}
22+
23+
location / {
24+
try_files $uri $uri/ @octane;
25+
}
26+
27+
location = /favicon.ico { access_log off; log_not_found off; }
28+
location = /robots.txt { access_log off; log_not_found off; }
29+
30+
access_log off;
31+
error_log /var/log/nginx/site.com-error.log error;
32+
33+
error_page 404 /index.php;
34+
35+
location @octane {
36+
set $suffix "";
37+
38+
if ($uri = /index.php) {
39+
set $suffix ?$query_string;
40+
}
41+
42+
proxy_http_version 1.1;
43+
proxy_set_header Host $http_host;
44+
proxy_set_header Scheme $scheme;
45+
proxy_set_header SERVER_PORT $server_port;
46+
proxy_set_header REMOTE_ADDR $remote_addr;
47+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
48+
proxy_set_header Upgrade $http_upgrade;
49+
proxy_set_header Connection $connection_upgrade;
50+
51+
proxy_pass http://127.0.0.1:8000$suffix;
52+
}
53+
}

8.1/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+

8.1/config/supervisord.conf

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[program:php-fpm]
2+
command=php-fpm8 -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:laravel-octane]
33+
# roadrunner
34+
# command=/usr/bin/php -d variables_order=EGPCS /var/www/site/artisan octane:start --server=roadrunner --host=0.0.0.0 --rpc-port=6001 --port=8000
35+
# swoole
36+
# command=/usr/bin/php -d variables_order=EGPCS /var/www/site/artisan octane:start --server=swoole --host=0.0.0.0 --port=8000
37+
#
38+
command=/usr/bin/php -d variables_order=EGPCS /var/www/site/artisan octane:start --host=0.0.0.0 --port=8000 --max-requests=250
39+
user=www-data
40+
stdout_logfile=/dev/stdout
41+
stdout_logfile_maxbytes=0
42+
stderr_logfile=/dev/stderr
43+
stderr_logfile_maxbytes=0
44+
45+
[program:nginx]
46+
command=nginx
47+
stdout_logfile=/dev/stdout
48+
stdout_logfile_maxbytes=0
49+
stderr_logfile=/dev/stderr
50+
stderr_logfile_maxbytes=0
51+
autorestart=true
52+
startretries=3

8.1/nginx.conf

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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_tokens off;
56+
57+
# server {
58+
# listen 80;
59+
# listen [::]:80;
60+
61+
# # For https
62+
# # listen 443 ssl;
63+
# # listen [::]:443 ssl ipv6only=on;
64+
# # ssl_certificate /etc/nginx/ssl/default.crt;
65+
# # ssl_certificate_key /etc/nginx/ssl/default.key;
66+
67+
# server_name localhost;
68+
# root /var/www/;
69+
# index index.php index.html index.htm;
70+
71+
# location ~ \.php$ {
72+
# try_files $uri /index.php =404;
73+
# # fastcgi_pass php-upstream;
74+
# # fastcgi_pass unix:/run/php/php-fpm7.sock;
75+
# fastcgi_pass 127.0.0.1:9000;
76+
# fastcgi_index index.php;
77+
# fastcgi_buffers 16 16k;
78+
# fastcgi_buffer_size 32k;
79+
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
80+
# #fixes timeouts
81+
# fastcgi_read_timeout 600;
82+
# include fastcgi_params;
83+
# }
84+
# }
85+
86+
# include /etc/nginx/conf.d/*.conf;
87+
include /etc/nginx/sites-available/*.conf;
88+
}

0 commit comments

Comments
 (0)