@@ -5,7 +5,156 @@ COPY . /app
55RUN composer install --no-ansi --no-interaction --no-progress --no-scripts --ignore-platform-reqs \
66 && vendor/bin/box compile
77
8- FROM roquie/docker-swoole-webapp:php7.3-latest-brotli
8+ FROM php:7.4-cli-alpine
9+
10+ ENV NGINX_VERSION 1.16.1
11+ ENV NGX_BROTLI_COMMIT e505dce68acc190cc5a1e780a3b0275e39f160ca
12+
13+ RUN set -xe \
14+ apk update --no-cache \
15+ && apk add --no-cache ca-certificates \
16+ && docker-php-ext-install pcntl \
17+ && mkdir /run/nginx
18+
19+ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \
20+ && CONFIG="\
21+ --prefix=/etc/nginx \
22+ --sbin-path=/usr/sbin/nginx \
23+ --modules-path=/usr/lib/nginx/modules \
24+ --conf-path=/etc/nginx/nginx.conf \
25+ --error-log-path=/var/log/nginx/error.log \
26+ --http-log-path=/var/log/nginx/access.log \
27+ --pid-path=/var/run/nginx.pid \
28+ --lock-path=/var/run/nginx.lock \
29+ --http-client-body-temp-path=/var/cache/nginx/client_temp \
30+ --http-proxy-temp-path=/var/cache/nginx/proxy_temp \
31+ --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
32+ --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
33+ --http-scgi-temp-path=/var/cache/nginx/scgi_temp \
34+ --user=nginx \
35+ --group=nginx \
36+ --with-http_ssl_module \
37+ --with-http_realip_module \
38+ --with-http_addition_module \
39+ --with-http_sub_module \
40+ --with-http_dav_module \
41+ --with-http_flv_module \
42+ --with-http_mp4_module \
43+ --with-http_gunzip_module \
44+ --with-http_gzip_static_module \
45+ --with-http_random_index_module \
46+ --with-http_secure_link_module \
47+ --with-http_stub_status_module \
48+ --with-http_auth_request_module \
49+ --with-http_xslt_module=dynamic \
50+ --with-http_image_filter_module=dynamic \
51+ --with-http_geoip_module=dynamic \
52+ --with-http_perl_module=dynamic \
53+ --with-threads \
54+ --with-stream \
55+ --with-stream_ssl_module \
56+ --with-stream_ssl_preread_module \
57+ --with-stream_realip_module \
58+ --with-stream_geoip_module=dynamic \
59+ --with-http_slice_module \
60+ --with-mail \
61+ --with-mail_ssl_module \
62+ --with-compat \
63+ --with-file-aio \
64+ --with-http_v2_module \
65+ --add-module=/usr/src/ngx_brotli \
66+ " \
67+ && addgroup -S nginx \
68+ && adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \
69+ && apk add --no-cache --virtual .build-deps \
70+ gcc \
71+ libc-dev \
72+ make \
73+ openssl-dev \
74+ pcre-dev \
75+ zlib-dev \
76+ linux-headers \
77+ curl \
78+ gnupg1 \
79+ libxslt-dev \
80+ gd-dev \
81+ geoip-dev \
82+ perl-dev \
83+ && apk add --no-cache --virtual .brotli-build-deps \
84+ autoconf \
85+ libtool \
86+ automake \
87+ git \
88+ g++ \
89+ cmake \
90+ && mkdir -p /usr/src \
91+ && cd /usr/src \
92+ && git clone --recursive https://github.com/google/ngx_brotli.git \
93+ && cd ngx_brotli \
94+ && git checkout -b $NGX_BROTLI_COMMIT $NGX_BROTLI_COMMIT \
95+ && cd .. \
96+ && curl -fSL https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \
97+ && curl -fSL https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz.asc -o nginx.tar.gz.asc \
98+ && sha512sum nginx.tar.gz nginx.tar.gz.asc \
99+ && export GNUPGHOME="$(mktemp -d)" \
100+ && gpg --keyserver ipv4.pool.sks-keyservers.net --recv-keys "$GPG_KEYS" \
101+ && gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz \
102+ && rm -rf "$GNUPGHOME" nginx.tar.gz.asc \
103+ && mkdir -p /usr/src \
104+ && tar -zxC /usr/src -f nginx.tar.gz \
105+ && rm nginx.tar.gz \
106+ && cd /usr/src/nginx-$NGINX_VERSION \
107+ && ./configure $CONFIG --with-debug \
108+ && make -j$(getconf _NPROCESSORS_ONLN) \
109+ && mv objs/nginx objs/nginx-debug \
110+ && mv objs/ngx_http_xslt_filter_module.so objs/ngx_http_xslt_filter_module-debug.so \
111+ && mv objs/ngx_http_image_filter_module.so objs/ngx_http_image_filter_module-debug.so \
112+ && mv objs/ngx_http_geoip_module.so objs/ngx_http_geoip_module-debug.so \
113+ && mv objs/ngx_http_perl_module.so objs/ngx_http_perl_module-debug.so \
114+ && mv objs/ngx_stream_geoip_module.so objs/ngx_stream_geoip_module-debug.so \
115+ && ./configure $CONFIG \
116+ && make -j$(getconf _NPROCESSORS_ONLN) \
117+ && make install \
118+ && rm -rf /etc/nginx/html/ \
119+ && mkdir /etc/nginx/conf.d/ \
120+ && mkdir -p /usr/share/nginx/html/ \
121+ && install -m644 html/index.html /usr/share/nginx/html/ \
122+ && install -m644 html/50x.html /usr/share/nginx/html/ \
123+ && install -m755 objs/nginx-debug /usr/sbin/nginx-debug \
124+ && install -m755 objs/ngx_http_xslt_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_xslt_filter_module-debug.so \
125+ && install -m755 objs/ngx_http_image_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_image_filter_module-debug.so \
126+ && install -m755 objs/ngx_http_geoip_module-debug.so /usr/lib/nginx/modules/ngx_http_geoip_module-debug.so \
127+ && install -m755 objs/ngx_http_perl_module-debug.so /usr/lib/nginx/modules/ngx_http_perl_module-debug.so \
128+ && install -m755 objs/ngx_stream_geoip_module-debug.so /usr/lib/nginx/modules/ngx_stream_geoip_module-debug.so \
129+ && ln -s ../../usr/lib/nginx/modules /etc/nginx/modules \
130+ && strip /usr/sbin/nginx* \
131+ && strip /usr/lib/nginx/modules/*.so \
132+ && rm -rf /usr/src/nginx-$NGINX_VERSION \
133+ && rm -rf /usr/src/ngx_brotli \
134+ \
135+ # Bring in gettext so we can get `envsubst`, then throw
136+ # the rest away. To do this, we need to install `gettext`
137+ # then move `envsubst` out of the way so `gettext` can
138+ # be deleted completely, then move `envsubst` back.
139+ && apk add --no-cache --virtual .gettext gettext \
140+ && mv /usr/bin/envsubst /tmp/ \
141+ \
142+ && runDeps="$( \
143+ scanelf --needed --nobanner /usr/sbin/nginx /usr/lib/nginx/modules/*.so /tmp/envsubst \
144+ | awk '{ gsub(/,/, " \n so:", $2); print " so:" $2 }' \
145+ | sort -u \
146+ | xargs -r apk info --installed \
147+ | sort -u \
148+ )" \
149+ && apk add --no-cache --virtual .nginx-rundeps tzdata $runDeps \
150+ && apk del .build-deps \
151+ && apk del .brotli-build-deps \
152+ && apk del .gettext \
153+ && mv /tmp/envsubst /usr/local/bin/ \
154+ \
155+ # forward request and error logs to docker log collector
156+ && ln -sf /dev/stdout /var/log/nginx/access.log \
157+ && ln -sf /dev/stderr /var/log/nginx/error.log
9158
10159COPY --from=0 /app/bin/server.phar /usr/bin/server
11160COPY --from=0 /app/dist /app
0 commit comments