-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathDockerfile
177 lines (165 loc) · 5.59 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
FROM php:8.2-fpm-alpine3.20
# RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# entrypoint.sh and dependencies
RUN set -ex; \
\
apk update && apk upgrade &&\
apk add --no-cache \
bash \
rsync \
supervisor \
imagemagick \
imagemagick-pdf \
imagemagick-jpeg \
imagemagick-raw \
imagemagick-tiff \
imagemagick-heic \
imagemagick-webp \
imagemagick-svg \
ffmpeg \
tzdata \
unzip \
p7zip \
nginx \
coreutils \
# forward request and error logs to docker log collector
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
&& mkdir -p /run/nginx \
&& mkdir -p /var/log/supervisor && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone
ADD conf/supervisord.conf /etc/supervisord.conf
# Copy our nginx config
RUN rm -Rf /etc/nginx/nginx.conf
ADD conf/nginx.conf /etc/nginx/nginx.conf
# nginx site conf
RUN mkdir -p /etc/nginx/sites-available/; \
mkdir -p /etc/nginx/sites-enabled/; \
mkdir -p /etc/nginx/ssl/; \
mkdir /var/www/html/; \
mkdir -p /docker-entrypoint-hooks.d/pre-installation \
/docker-entrypoint-hooks.d/post-installation \
/docker-entrypoint-hooks.d/pre-upgrade \
/docker-entrypoint-hooks.d/post-upgrade \
/docker-entrypoint-hooks.d/before-starting; \
chown -R nginx:root /var/www; \
chmod -R g=u /var/www
ADD conf/private-ssl.conf /etc/nginx/sites-available/private-ssl.conf
# install the PHP extensions we need
RUN set -ex; \
\
apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
autoconf \
freetype-dev \
icu-dev \
libevent-dev \
libjpeg-turbo-dev \
libmcrypt-dev \
libpng-dev \
libmemcached-dev \
libxml2-dev \
libzip-dev \
openldap-dev \
pcre-dev \
libwebp-dev \
bzip2-dev \
gettext-dev \
curl-dev \
imagemagick-dev \
; \
\
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \
docker-php-ext-configure intl; \
docker-php-ext-configure ldap; \
docker-php-ext-install -j "$(nproc)" \
bcmath \
exif \
ftp \
gd \
intl \
ldap \
opcache \
pcntl \
pdo_mysql \
mysqli \
zip \
bz2 \
gettext \
# sockets \
; \
\
# pecl will claim success even if one install fails, so we need to perform each install separately
pecl install memcached-3.3.0; \
pecl install redis-6.1.0; \
# pecl install mcrypt-1.0.5; \
pecl install imagick-3.7.0; \
# pecl install swoole-5.1.1; \
\
docker-php-ext-enable \
memcached \
redis \
# mcrypt \
imagick \
# swoole \
; \
rm -r /tmp/pear; \
\
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --no-network --virtual .kodbox-phpext-rundeps $runDeps; \
apk del --no-network .build-deps
# tweak php-fpm config
ENV fpm_conf /usr/local/etc/php-fpm.d/www.conf
ENV php_vars /usr/local/etc/php/conf.d/docker-vars.ini
RUN { \
echo 'opcache.enable=1'; \
echo 'opcache.interned_strings_buffer=32'; \
echo 'opcache.max_accelerated_files=10000'; \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.save_comments=1'; \
echo 'opcache.revalidate_freq=60'; \
echo 'opcache.jit=1255'; \
echo 'opcache.jit_buffer_size=128M'; \
} > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \
\
echo "cgi.fix_pathinfo=1" > ${php_vars} &&\
echo "upload_max_filesize = 512M" >> ${php_vars} &&\
echo "post_max_size = 512M" >> ${php_vars} &&\
echo "memory_limit = 512M" >> ${php_vars} && \
echo "max_execution_time = 3600" >> ${php_vars} && \
echo "max_input_time = 3600" >> ${php_vars} && \
sed -i \
-e "s/;catch_workers_output\s*=\s*yes/catch_workers_output = yes/g" \
-e "s/pm.max_children = 5/pm.max_children = 50/g" \
-e "s/pm.start_servers = 2/pm.start_servers = 10/g" \
-e "s/pm.min_spare_servers = 1/pm.min_spare_servers = 10/g" \
-e "s/pm.max_spare_servers = 3/pm.max_spare_servers = 30/g" \
-e "s/;pm.max_requests = 500/pm.max_requests = 500/g" \
-e "s/user = www-data/user = nginx/g" \
-e "s/group = www-data/group = nginx/g" \
-e "s/;listen.mode = 0660/listen.mode = 0666/g" \
-e "s/;listen.owner = www-data/listen.owner = nginx/g" \
-e "s/;listen.group = www-data/listen.group = nginx/g" \
-e "s/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g" \
-e "s/^;clear_env = no$/clear_env = no/" \
${fpm_conf}
VOLUME /var/www/html
RUN set -ex; \
curl -fsSL -o kodbox.zip \
"https://api.kodcloud.com/?app/version&download=server.link"; \
unzip kodbox.zip -d /usr/src/kodbox/; \
curl -fsSL -o update.zip \
"https://api.kodcloud.com/?app/version&download=server.linkUpdate"; \
mv update.zip /usr/src/kodbox/; \
sed -i "s/MyISAM/InnoDB/g" /usr/src/kodbox/app/controller/install/data/mysql.sql; \
rm kodbox.zip
COPY entrypoint.sh /
EXPOSE 80 443
ENTRYPOINT ["/entrypoint.sh"]
CMD ["supervisord","-n","-c","/etc/supervisord.conf"]