forked from chenyongze/docker-openresty-php-fpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
222 lines (202 loc) · 7.86 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# Use Alpine Linux
FROM php:7.2.10-fpm-alpine
# Maintainer
LABEL maintainer="Hamed Zarei <[email protected]>"
# Set Timezone Environments
ENV TIMEZONE Asia/Shanghai
RUN apk add --update tzdata \
&& cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
&& echo "${TIMEZONE}" > /etc/timezone \
&& apk del tzdata \
&& apk add --no-cache --virtual .build-deps \
curl \
g++ \
make \
autoconf \
openssl-dev \
libaio \
libaio-dev \
linux-headers \
zlib-dev \
&& apk add --no-cache \
bash \
openssh \
libssl1.0 \
libxslt-dev \
libjpeg-turbo-dev \
libwebp-dev \
libpng-dev \
libxml2-dev \
freetype-dev \
libmcrypt \
freetds-dev \
libmemcached-dev \
cyrus-sasl-dev \
&& docker-php-source extract \
&& docker-php-ext-configure pdo \
&& docker-php-ext-configure pdo_mysql \
&& docker-php-ext-configure mysqli \
&& docker-php-ext-configure opcache \
&& docker-php-ext-configure exif \
&& docker-php-ext-configure sockets \
&& docker-php-ext-configure soap \
&& docker-php-ext-configure bcmath \
&& docker-php-ext-configure pcntl \
&& docker-php-ext-configure sysvsem \
&& docker-php-ext-configure tokenizer \
&& docker-php-ext-configure zip \
&& docker-php-ext-configure xsl \
&& docker-php-ext-configure shmop \
&& docker-php-ext-configure gd \
--with-jpeg-dir=/usr/include \
--with-png-dir=/usr/include \
--with-webp-dir=/usr/include \
--with-freetype-dir=/usr/include \
&& pecl install swoole redis xdebug mongodb memcached \
&& pecl clear-cache \
&& docker-php-ext-enable swoole redis xdebug mongodb memcached \
&& docker-php-ext-install pdo \
pdo_mysql \
mysqli \
opcache \
exif \
sockets \
soap \
bcmath \
pcntl \
sysvsem \
tokenizer \
zip \
xsl \
shmop \
gd \
&& docker-php-source delete \
&& apk del .build-deps \
&& ln -sf /dev/stdout /usr/local/var/log/php-fpm.access.log \
&& ln -sf /dev/stderr /usr/local/var/log/php-fpm.error.log \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
&& curl --location --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit.phar \
&& chmod +x /usr/local/bin/phpunit
# install postgres connection for php
RUN apk update && apk add postgresql-dev \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install pgsql pdo_pgsql
# Docker Build Arguments
ARG RESTY_VERSION="1.13.6.2"
ARG RESTY_LUAROCKS_VERSION="2.4.3"
ARG RESTY_OPENSSL_VERSION="1.0.2k"
ARG RESTY_PCRE_VERSION="8.42"
ARG RESTY_J="1"
ARG RESTY_CONFIG_OPTIONS="\
--with-file-aio \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_geoip_module=dynamic \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_image_filter_module=dynamic \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-http_xslt_module=dynamic \
--with-ipv6 \
--with-mail \
--with-mail_ssl_module \
--with-md5-asm \
--with-pcre-jit \
--with-sha1-asm \
--with-stream \
--with-stream_ssl_module \
--with-threads \
"
ARG RESTY_CONFIG_OPTIONS_MORE=""
# These are not intended to be user-specified
ARG _RESTY_CONFIG_DEPS="--with-openssl=/tmp/openssl-${RESTY_OPENSSL_VERSION} --with-pcre=/tmp/pcre-${RESTY_PCRE_VERSION}"
# 1) Install apk dependencies
# 2) Download and untar OpenSSL, PCRE, and OpenResty
# 3) Build OpenResty
# 4) Cleanup
RUN apk add --no-cache --virtual .build-deps \
build-base \
curl \
gd-dev \
geoip-dev \
libxslt-dev \
linux-headers \
make \
perl-dev \
readline-dev \
zlib-dev \
&& apk add --no-cache \
gd \
geoip \
libgcc \
libxslt \
zlib \
supervisor \
bash \
&& cd /tmp \
&& curl -fSL https://www.openssl.org/source/openssl-${RESTY_OPENSSL_VERSION}.tar.gz -o openssl-${RESTY_OPENSSL_VERSION}.tar.gz \
&& tar xzf openssl-${RESTY_OPENSSL_VERSION}.tar.gz \
&& curl -fSL https://ftp.pcre.org/pub/pcre/pcre-${RESTY_PCRE_VERSION}.tar.gz -o pcre-${RESTY_PCRE_VERSION}.tar.gz \
&& tar xzf pcre-${RESTY_PCRE_VERSION}.tar.gz \
&& curl -fSL https://openresty.org/download/openresty-${RESTY_VERSION}.tar.gz -o openresty-${RESTY_VERSION}.tar.gz \
&& tar xzf openresty-${RESTY_VERSION}.tar.gz \
&& cd /tmp/openresty-${RESTY_VERSION} \
&& ./configure -j${RESTY_J} ${_RESTY_CONFIG_DEPS} ${RESTY_CONFIG_OPTIONS} ${RESTY_CONFIG_OPTIONS_MORE} \
&& make -j${RESTY_J} \
&& make -j${RESTY_J} install \
&& cd /tmp \
&& rm -rf \
openssl-${RESTY_OPENSSL_VERSION} \
openssl-${RESTY_OPENSSL_VERSION}.tar.gz \
openresty-${RESTY_VERSION}.tar.gz openresty-${RESTY_VERSION} \
pcre-${RESTY_PCRE_VERSION}.tar.gz pcre-${RESTY_PCRE_VERSION} \
# install luarock
&& curl -fSL https://github.com/luarocks/luarocks/archive/${RESTY_LUAROCKS_VERSION}.tar.gz -o luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \
&& tar xzf luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \
&& cd luarocks-${RESTY_LUAROCKS_VERSION} \
&& ./configure \
--prefix=/usr/local/openresty/luajit \
--with-lua=/usr/local/openresty/luajit \
--lua-suffix=jit-2.1.0-beta3 \
--with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1 \
&& make build \
&& make install \
&& cd /tmp \
&& rm -rf luarocks-${RESTY_LUAROCKS_VERSION} luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \
&& apk del .build-deps \
&& ln -sf /dev/stdout /usr/local/openresty/nginx/logs/access.log \
&& ln -sf /dev/stderr /usr/local/openresty/nginx/logs/error.log \
&& rm -rf /usr/local/openresty/nginx/html/*
# Add additional binaries into PATH for convenience
ENV PATH=$PATH:/usr/local/openresty/luajit/bin/:/usr/local/openresty/nginx/sbin/:/usr/local/openresty/bin/
# Add lua module for json, hash, jwt, http request
RUN apk add gcc && apk add musl-dev
RUN apk add git
RUN luarocks install luasocket \
&& luarocks install inspect \
&& luarocks install httpclient \
&& luarocks install json-lua \
&& luarocks install murmurhash3 \
&& luarocks install lua-resty-jwt
# Copy nginx configuration files
COPY conf/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
COPY conf/nginx.vh.default.conf /etc/nginx/conf.d/default.conf
# Copy php configuration files
COPY conf/php/etc/php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf
# Copy supervisord configuration file
COPY conf/supervisord.conf /etc/supervisord.conf
# copy in code
COPY src/ /usr/local/openresty/nginx/html/
WORKDIR /usr/local/openresty/nginx/html/
EXPOSE 443 80 9000
CMD ["/usr/bin/supervisord", "-n","-c", "/etc/supervisord.conf"]