|
1 |
| -# Use Alpine Linux |
2 |
| -FROM php:7.2.10-fpm-alpine |
3 |
| - |
4 |
| -# Maintainer |
5 |
| -LABEL maintainer= "yongze.chen <[email protected]>" |
6 |
| - |
7 |
| -# Set Timezone Environments |
8 |
| -ENV TIMEZONE Asia/Shanghai |
9 |
| - |
10 |
| -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories |
11 |
| - |
12 |
| -RUN apk add --update tzdata \ |
13 |
| - && cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \ |
14 |
| - && echo "${TIMEZONE}" > /etc/timezone \ |
15 |
| - && apk del tzdata \ |
16 |
| - && apk add --no-cache --virtual .build-deps \ |
17 |
| - curl \ |
18 |
| - g++ \ |
19 |
| - make \ |
20 |
| - autoconf \ |
21 |
| - openssl-dev \ |
22 |
| - libaio \ |
23 |
| - libaio-dev \ |
24 |
| - linux-headers \ |
25 |
| - zlib-dev \ |
26 |
| - && apk add --no-cache \ |
27 |
| - bash \ |
28 |
| - openssh \ |
29 |
| - libssl1.0 \ |
30 |
| - libxslt-dev \ |
31 |
| - libjpeg-turbo-dev \ |
32 |
| - libwebp-dev \ |
33 |
| - libpng-dev \ |
34 |
| - libxml2-dev \ |
35 |
| - freetype-dev \ |
36 |
| - libmcrypt \ |
37 |
| - freetds-dev \ |
38 |
| - libmemcached-dev \ |
39 |
| - cyrus-sasl-dev \ |
| 1 | +FROM php:7.3-fpm-alpine3.13 |
| 2 | +LABEL MAINTAINER= "Yongze Chen <[email protected]>" |
| 3 | + |
| 4 | +ENV CONTAINER_PACKAGE_URL mirrors.aliyun.com |
| 5 | +ENV TZ "Asia/Shanghai" |
| 6 | +ENV PHP_EXTENSIONS "redis mongodb swoole" |
| 7 | + |
| 8 | +#资源替换 国内 |
| 9 | +RUN sed -i "s/dl-cdn.alpinelinux.org/$CONTAINER_PACKAGE_URL/g" /etc/apk/repositories |
| 10 | + |
| 11 | +RUN apk add --no-cache --repository https://mirrors.aliyun.com/alpine/edge/testing gnu-libiconv |
| 12 | +ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php |
| 13 | + |
| 14 | +RUN apk add --no-cache --virtual .build-deps \ |
| 15 | + tzdata \ |
| 16 | + && cp /usr/share/zoneinfo/${TZ} /etc/localtime \ |
| 17 | + && echo "${TZ}" > /etc/timezone \ |
| 18 | + && apk del .build-deps |
| 19 | + |
| 20 | +RUN apk add --no-cache --virtual .build-deps \ |
| 21 | + $PHPIZE_DEPS \ |
| 22 | + supervisor \ |
| 23 | + libpng \ |
| 24 | + curl \ |
| 25 | + g++ \ |
| 26 | + make \ |
| 27 | + autoconf \ |
| 28 | + openssl-dev \ |
| 29 | + libaio \ |
| 30 | + libaio-dev \ |
| 31 | + linux-headers \ |
| 32 | + zlib-dev \ |
| 33 | + libzip-dev \ |
| 34 | + bash \ |
| 35 | + openssh \ |
| 36 | + libxslt-dev \ |
| 37 | + libjpeg-turbo-dev \ |
| 38 | + libwebp-dev \ |
| 39 | + libpng-dev \ |
| 40 | + libxml2-dev \ |
| 41 | + freetype-dev \ |
| 42 | + libmcrypt \ |
| 43 | + freetds-dev \ |
| 44 | + libmemcached-dev \ |
| 45 | + cyrus-sasl-dev \ |
40 | 46 | && docker-php-source extract \
|
41 |
| - && docker-php-ext-configure pdo \ |
42 |
| - && docker-php-ext-configure pdo_mysql \ |
43 |
| - && docker-php-ext-configure mysqli \ |
44 |
| - && docker-php-ext-configure opcache \ |
45 |
| - && docker-php-ext-configure exif \ |
46 |
| - && docker-php-ext-configure sockets \ |
47 |
| - && docker-php-ext-configure soap \ |
48 |
| - && docker-php-ext-configure bcmath \ |
49 |
| - && docker-php-ext-configure pcntl \ |
50 |
| - && docker-php-ext-configure sysvsem \ |
51 |
| - && docker-php-ext-configure tokenizer \ |
52 |
| - && docker-php-ext-configure zip \ |
53 |
| - && docker-php-ext-configure xsl \ |
54 |
| - && docker-php-ext-configure shmop \ |
55 | 47 | && docker-php-ext-configure gd \
|
56 |
| - --with-jpeg-dir=/usr/include \ |
57 |
| - --with-png-dir=/usr/include \ |
58 |
| - --with-webp-dir=/usr/include \ |
59 |
| - --with-freetype-dir=/usr/include \ |
60 |
| - && pecl install swoole redis xdebug mongodb memcached \ |
61 |
| - && pecl clear-cache \ |
62 |
| - && docker-php-ext-enable swoole redis xdebug mongodb memcached \ |
63 |
| - && docker-php-ext-install pdo \ |
64 |
| - pdo_mysql \ |
65 |
| - mysqli \ |
66 |
| - opcache \ |
67 |
| - exif \ |
68 |
| - sockets \ |
69 |
| - soap \ |
70 |
| - bcmath \ |
71 |
| - pcntl \ |
72 |
| - sysvsem \ |
73 |
| - tokenizer \ |
74 |
| - zip \ |
75 |
| - xsl \ |
76 |
| - shmop \ |
77 |
| - gd \ |
78 |
| - && docker-php-source delete \ |
79 |
| - && apk del .build-deps \ |
| 48 | + --with-jpeg-dir=/usr/include \ |
| 49 | + --with-png-dir=/usr/include \ |
| 50 | + --with-webp-dir=/usr/include \ |
| 51 | + --with-freetype-dir=/usr/include \ |
| 52 | + && docker-php-ext-install -j5\ |
| 53 | + pdo_mysql \ |
| 54 | + mysqli \ |
| 55 | + opcache \ |
| 56 | + exif \ |
| 57 | + sockets \ |
| 58 | + soap \ |
| 59 | + bcmath \ |
| 60 | + pcntl \ |
| 61 | + sysvsem \ |
| 62 | + shmop \ |
| 63 | + gd \ |
| 64 | + && pecl install ${PHP_EXTENSIONS} \ |
| 65 | + && docker-php-ext-enable ${PHP_EXTENSIONS} \ |
80 | 66 | && ln -sf /dev/stdout /usr/local/var/log/php-fpm.access.log \
|
81 |
| - && ln -sf /dev/stderr /usr/local/var/log/php-fpm.error.log \ |
82 |
| - && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \ |
83 |
| - && curl --location --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit.phar \ |
84 |
| - && chmod +x /usr/local/bin/phpunit |
| 67 | + && ln -sf /dev/stderr /usr/local/var/log/php-fpm.error.log \ |
| 68 | + && docker-php-source delete \ |
| 69 | + && pecl clear-cache |
| 70 | + |
| 71 | + |
| 72 | +# Copy php configuration files |
| 73 | +# COPY conf/php/etc/php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf |
| 74 | +COPY php/php.ini /usr/local/etc/php/php.ini |
| 75 | +COPY php/php-fpm.d /usr/local/etc/php-fpm.d |
| 76 | + |
85 | 77 |
|
| 78 | +# Dockerfile - alpine |
| 79 | +# https://github.com/openresty/docker-openresty |
86 | 80 |
|
87 | 81 | # Docker Build Arguments
|
88 |
| -ARG RESTY_VERSION="1.13.6.2" |
89 |
| -ARG RESTY_OPENSSL_VERSION="1.0.2k" |
90 |
| -ARG RESTY_PCRE_VERSION="8.42" |
| 82 | +ARG RESTY_IMAGE_BASE="alpine" |
| 83 | +ARG RESTY_IMAGE_TAG="3.14" |
| 84 | +ARG RESTY_VERSION="1.19.9.1" |
| 85 | +ARG RESTY_OPENSSL_VERSION="1.1.1l" |
| 86 | +ARG RESTY_OPENSSL_PATCH_VERSION="1.1.1f" |
| 87 | +ARG RESTY_OPENSSL_URL_BASE="https://www.openssl.org/source" |
| 88 | +ARG RESTY_PCRE_VERSION="8.44" |
91 | 89 | ARG RESTY_J="1"
|
92 | 90 | ARG RESTY_CONFIG_OPTIONS="\
|
| 91 | + --with-compat \ |
93 | 92 | --with-file-aio \
|
94 | 93 | --with-http_addition_module \
|
95 | 94 | --with-http_auth_request_module \
|
@@ -120,74 +119,134 @@ ARG RESTY_CONFIG_OPTIONS="\
|
120 | 119 | --with-threads \
|
121 | 120 | "
|
122 | 121 | ARG RESTY_CONFIG_OPTIONS_MORE=""
|
| 122 | +ARG RESTY_LUAJIT_OPTIONS="--with-luajit-xcflags='-DLUAJIT_NUMMODE=2 -DLUAJIT_ENABLE_LUA52COMPAT'" |
| 123 | + |
| 124 | +ARG RESTY_ADD_PACKAGE_BUILDDEPS="" |
| 125 | +ARG RESTY_ADD_PACKAGE_RUNDEPS="" |
| 126 | +ARG RESTY_EVAL_PRE_CONFIGURE="" |
| 127 | +ARG RESTY_EVAL_POST_MAKE="" |
123 | 128 |
|
124 | 129 | # These are not intended to be user-specified
|
125 |
| -ARG _RESTY_CONFIG_DEPS="--with-openssl=/tmp/openssl-${RESTY_OPENSSL_VERSION} --with-pcre=/tmp/pcre-${RESTY_PCRE_VERSION}" |
| 130 | +ARG _RESTY_CONFIG_DEPS="--with-pcre \ |
| 131 | + --with-cc-opt='-DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl/include' \ |
| 132 | + --with-ld-opt='-L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl/lib -Wl,-rpath,/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl/lib' \ |
| 133 | + " |
| 134 | + |
| 135 | +LABEL resty_image_base="${RESTY_IMAGE_BASE}" |
| 136 | +LABEL resty_image_tag="${RESTY_IMAGE_TAG}" |
| 137 | +LABEL resty_version="${RESTY_VERSION}" |
| 138 | +LABEL resty_openssl_version="${RESTY_OPENSSL_VERSION}" |
| 139 | +LABEL resty_openssl_patch_version="${RESTY_OPENSSL_PATCH_VERSION}" |
| 140 | +LABEL resty_openssl_url_base="${RESTY_OPENSSL_URL_BASE}" |
| 141 | +LABEL resty_pcre_version="${RESTY_PCRE_VERSION}" |
| 142 | +LABEL resty_config_options="${RESTY_CONFIG_OPTIONS}" |
| 143 | +LABEL resty_config_options_more="${RESTY_CONFIG_OPTIONS_MORE}" |
| 144 | +LABEL resty_config_deps="${_RESTY_CONFIG_DEPS}" |
| 145 | +LABEL resty_add_package_builddeps="${RESTY_ADD_PACKAGE_BUILDDEPS}" |
| 146 | +LABEL resty_add_package_rundeps="${RESTY_ADD_PACKAGE_RUNDEPS}" |
| 147 | +LABEL resty_eval_pre_configure="${RESTY_EVAL_PRE_CONFIGURE}" |
| 148 | +LABEL resty_eval_post_make="${RESTY_EVAL_POST_MAKE}" |
126 | 149 |
|
127 |
| -# 1) Install apk dependencies |
128 |
| -# 2) Download and untar OpenSSL, PCRE, and OpenResty |
129 |
| -# 3) Build OpenResty |
130 |
| -# 4) Cleanup |
131 | 150 |
|
132 | 151 | RUN apk add --no-cache --virtual .build-deps \
|
133 |
| - build-base \ |
134 |
| - curl \ |
135 |
| - gd-dev \ |
136 |
| - geoip-dev \ |
137 |
| - libxslt-dev \ |
138 |
| - linux-headers \ |
139 |
| - make \ |
140 |
| - perl-dev \ |
141 |
| - readline-dev \ |
142 |
| - zlib-dev \ |
| 152 | + build-base \ |
| 153 | + coreutils \ |
| 154 | + curl \ |
| 155 | + gd-dev \ |
| 156 | + geoip-dev \ |
| 157 | + libxslt-dev \ |
| 158 | + linux-headers \ |
| 159 | + make \ |
| 160 | + perl-dev \ |
| 161 | + readline-dev \ |
| 162 | + zlib-dev \ |
| 163 | + ${RESTY_ADD_PACKAGE_BUILDDEPS} \ |
143 | 164 | && apk add --no-cache \
|
144 |
| - gd \ |
145 |
| - geoip \ |
146 |
| - libgcc \ |
147 |
| - libxslt \ |
148 |
| - zlib \ |
149 |
| - supervisor \ |
150 |
| - bash \ |
| 165 | + gd \ |
| 166 | + geoip \ |
| 167 | + libgcc \ |
| 168 | + libxslt \ |
| 169 | + zlib \ |
| 170 | + ${RESTY_ADD_PACKAGE_RUNDEPS} \ |
151 | 171 | && cd /tmp \
|
152 |
| - && curl -fSL https://www.openssl.org/source/openssl-${RESTY_OPENSSL_VERSION}.tar.gz -o openssl-${RESTY_OPENSSL_VERSION}.tar.gz \ |
| 172 | + && if [ -n "${RESTY_EVAL_PRE_CONFIGURE}" ]; then eval $(echo ${RESTY_EVAL_PRE_CONFIGURE}); fi \ |
| 173 | + && cd /tmp \ |
| 174 | + && curl -fSL "${RESTY_OPENSSL_URL_BASE}/openssl-${RESTY_OPENSSL_VERSION}.tar.gz" -o openssl-${RESTY_OPENSSL_VERSION}.tar.gz \ |
153 | 175 | && tar xzf openssl-${RESTY_OPENSSL_VERSION}.tar.gz \
|
| 176 | + && cd openssl-${RESTY_OPENSSL_VERSION} \ |
| 177 | + && if [ $(echo ${RESTY_OPENSSL_VERSION} | cut -c 1-5) = "1.1.1" ] ; then \ |
| 178 | + echo 'patching OpenSSL 1.1.1 for OpenResty' \ |
| 179 | + && curl -s https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-${RESTY_OPENSSL_PATCH_VERSION}-sess_set_get_cb_yield.patch | patch -p1 ; \ |
| 180 | + fi \ |
| 181 | + && if [ $(echo ${RESTY_OPENSSL_VERSION} | cut -c 1-5) = "1.1.0" ] ; then \ |
| 182 | + echo 'patching OpenSSL 1.1.0 for OpenResty' \ |
| 183 | + && curl -s https://raw.githubusercontent.com/openresty/openresty/ed328977028c3ec3033bc25873ee360056e247cd/patches/openssl-1.1.0j-parallel_build_fix.patch | patch -p1 \ |
| 184 | + && curl -s https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-${RESTY_OPENSSL_PATCH_VERSION}-sess_set_get_cb_yield.patch | patch -p1 ; \ |
| 185 | + fi \ |
| 186 | + && ./config \ |
| 187 | + no-threads shared zlib -g \ |
| 188 | + enable-ssl3 enable-ssl3-method \ |
| 189 | + --prefix=/usr/local/openresty/openssl \ |
| 190 | + --libdir=lib \ |
| 191 | + -Wl,-rpath,/usr/local/openresty/openssl/lib \ |
| 192 | + && make -j${RESTY_J} \ |
| 193 | + && make -j${RESTY_J} install_sw \ |
| 194 | + && cd /tmp \ |
154 | 195 | && curl -fSL https://ftp.pcre.org/pub/pcre/pcre-${RESTY_PCRE_VERSION}.tar.gz -o pcre-${RESTY_PCRE_VERSION}.tar.gz \
|
155 | 196 | && tar xzf pcre-${RESTY_PCRE_VERSION}.tar.gz \
|
| 197 | + && cd /tmp/pcre-${RESTY_PCRE_VERSION} \ |
| 198 | + && ./configure \ |
| 199 | + --prefix=/usr/local/openresty/pcre \ |
| 200 | + --disable-cpp \ |
| 201 | + --enable-jit \ |
| 202 | + --enable-utf \ |
| 203 | + --enable-unicode-properties \ |
| 204 | + && make -j${RESTY_J} \ |
| 205 | + && make -j${RESTY_J} install \ |
| 206 | + && cd /tmp \ |
156 | 207 | && curl -fSL https://openresty.org/download/openresty-${RESTY_VERSION}.tar.gz -o openresty-${RESTY_VERSION}.tar.gz \
|
157 | 208 | && tar xzf openresty-${RESTY_VERSION}.tar.gz \
|
158 | 209 | && cd /tmp/openresty-${RESTY_VERSION} \
|
159 |
| - && ./configure -j${RESTY_J} ${_RESTY_CONFIG_DEPS} ${RESTY_CONFIG_OPTIONS} ${RESTY_CONFIG_OPTIONS_MORE} \ |
| 210 | + && eval ./configure -j${RESTY_J} ${_RESTY_CONFIG_DEPS} ${RESTY_CONFIG_OPTIONS} ${RESTY_CONFIG_OPTIONS_MORE} ${RESTY_LUAJIT_OPTIONS} \ |
160 | 211 | && make -j${RESTY_J} \
|
161 | 212 | && make -j${RESTY_J} install \
|
162 | 213 | && cd /tmp \
|
| 214 | + && if [ -n "${RESTY_EVAL_POST_MAKE}" ]; then eval $(echo ${RESTY_EVAL_POST_MAKE}); fi \ |
163 | 215 | && rm -rf \
|
164 |
| - openssl-${RESTY_OPENSSL_VERSION} \ |
165 |
| - openssl-${RESTY_OPENSSL_VERSION}.tar.gz \ |
166 |
| - openresty-${RESTY_VERSION}.tar.gz openresty-${RESTY_VERSION} \ |
167 |
| - pcre-${RESTY_PCRE_VERSION}.tar.gz pcre-${RESTY_PCRE_VERSION} \ |
| 216 | + openssl-${RESTY_OPENSSL_VERSION}.tar.gz openssl-${RESTY_OPENSSL_VERSION} \ |
| 217 | + pcre-${RESTY_PCRE_VERSION}.tar.gz pcre-${RESTY_PCRE_VERSION} \ |
| 218 | + openresty-${RESTY_VERSION}.tar.gz openresty-${RESTY_VERSION} \ |
168 | 219 | && apk del .build-deps \
|
| 220 | + && mkdir -p /var/run/openresty \ |
169 | 221 | && ln -sf /dev/stdout /usr/local/openresty/nginx/logs/access.log \
|
170 |
| - && ln -sf /dev/stderr /usr/local/openresty/nginx/logs/error.log \ |
171 |
| - && rm -rf /usr/local/openresty/nginx/html/* |
| 222 | + && ln -sf /dev/stderr /usr/local/openresty/nginx/logs/error.log |
172 | 223 |
|
173 | 224 | # Add additional binaries into PATH for convenience
|
174 |
| -ENV PATH=$PATH:/usr/local/openresty/luajit/bin/:/usr/local/openresty/nginx/sbin/:/usr/local/openresty/bin/ |
| 225 | +ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin |
175 | 226 |
|
176 |
| -# Copy nginx configuration files |
177 |
| -COPY conf/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf |
178 |
| -COPY conf/nginx.vh.default.conf /etc/nginx/conf.d/default.conf |
| 227 | +# # Copy nginx configuration files |
| 228 | +# COPY nginx.conf /usr/local/openresty/nginx/conf/nginx.conf |
| 229 | +# COPY nginx.vh.default.conf /etc/nginx/conf.d/default.conf |
| 230 | +COPY nginx/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf |
| 231 | +COPY nginx/conf.d /etc/nginx/conf.d |
| 232 | + |
| 233 | +# CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;"] |
| 234 | + |
| 235 | +# # Use SIGQUIT instead of default SIGTERM to cleanly drain requests |
| 236 | +# # See https://github.com/openresty/docker-openresty/blob/master/README.md#tips--pitfalls |
| 237 | +# STOPSIGNAL SIGQUIT |
179 | 238 |
|
180 |
| -# Copy php configuration files |
181 |
| -COPY conf/php/etc/php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf |
182 | 239 |
|
183 | 240 | # Copy supervisord configuration file
|
184 |
| -COPY conf/supervisord.conf /etc/supervisord.conf |
| 241 | +# COPY conf/supervisord.conf /etc/supervisord.conf |
| 242 | +COPY supervisor/supervisord.conf /etc/supervisord.conf |
| 243 | +COPY supervisor/conf.d /etc/supervisor/conf.d |
185 | 244 |
|
186 |
| -# copy in code |
187 |
| -COPY src/ /usr/local/openresty/nginx/html/ |
| 245 | +COPY ./crontab /tmp/crontab |
| 246 | +RUN crontab /tmp/crontab/test.crontab |
188 | 247 |
|
189 |
| -WORKDIR /usr/local/openresty/nginx/html/ |
| 248 | +WORKDIR /usr/local/openresty/nginx/html |
190 | 249 |
|
191 |
| -EXPOSE 443 80 9000 |
| 250 | +EXPOSE 80 443 9000 |
192 | 251 |
|
193 | 252 | CMD ["/usr/bin/supervisord", "-n","-c", "/etc/supervisord.conf"]
|
0 commit comments