-
Notifications
You must be signed in to change notification settings - Fork 7
/
php-dev-8.dockerfile
264 lines (235 loc) · 8.66 KB
/
php-dev-8.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
FROM php:8.0.0-fpm-alpine
ENV TERM="xterm" \
LANG="C.UTF-8" \
LC_ALL="C.UTF-8"
ENV DOCKER_CONF_HOME=/opt/docker/
ENV APPLICATION_USER=application \
APPLICATION_GROUP=application \
APPLICATION_PATH=/app \
APPLICATION_UID=1000 \
APPLICATION_GID=1000
ENV WEB_DOCUMENT_ROOT=/app \
WEB_DOCUMENT_INDEX=index.php \
WEB_ALIAS_DOMAIN=*.vm \
WEB_PHP_TIMEOUT=600 \
WEB_PHP_SOCKET=localhost:9000 \
NGINX_CLIENT_MAX_BODY=50m \
WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$"
ENV NGINX_VERSION 1.19.1
ENV NGX_BROTLI_COMMIT 25f86f0bac1101b6512135eac5f93c49c63609e3
ENV XDEBUG_VERSION="3.0.0"
ENV IS_CLI=false
ENV IS_ALPINE=true
COPY conf/ /opt/docker/
# install dependencies
RUN apk add --no-cache \
aom-dev \
bash-completion \
curl \
gd-dev \
geoip-dev \
git \
gnupg1 \
imagemagick \
jpegoptim \
less \
libffi-dev \
libgit2 \
libwebp-tools \
libxslt-dev \
make \
mariadb-client \
openssh \
openssl-dev \
optipng \
pcre-dev \
pngquant \
sshpass \
sudo \
supervisor \
tree \
unzip \
vim \
wget \
zip \
zlib-dev \
&& apk add --no-cache --virtual .build-deps \
autoconf \
automake \
cargo \
cmake \
g++ \
gcc \
gettext \
go \
libc-dev \
libtool \
linux-headers \
musl-dev \
perl-dev \
rust
# Add groups and users
RUN addgroup -S nginx \
&& adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx
RUN addgroup -g $APPLICATION_GID $APPLICATION_GROUP \
&& echo "%$APPLICATION_GROUP ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$APPLICATION_USER \
&& adduser -D -u $APPLICATION_UID -s /bin/bash -G $APPLICATION_GROUP $APPLICATION_USER \
&& addgroup $APPLICATION_USER nginx
RUN mkdir -p /usr/src \
&& cd /usr/src \
&& git clone --recursive https://github.com/google/ngx_brotli.git \
&& cd ngx_brotli \
&& git submodule update --init --recursive \
&& cd deps/brotli \
&& mkdir out \
&& cd out \
&& cmake .. \
&& make -j 16 brotli \
&& cp brotli /usr/local/bin/brotli
RUN cd /usr/src \
&& curl -fSL https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \
&& mkdir -p /usr/src \
&& tar -zxC /usr/src -f nginx.tar.gz \
&& rm nginx.tar.gz \
&& cd /usr/src/nginx-$NGINX_VERSION \
&& ls -la /usr/src/ngx_brotli \
&& CONFIG=" \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-http_perl_module=dynamic \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-threads \
--with-stream \
--with-compat \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-http_slice_module \
--with-http_v2_module \
--with-debug \
--add-dynamic-module=/usr/src/ngx_brotli \
" \
&& ./configure $CONFIG \
&& make \
&& make install
RUN mkdir -p /etc/nginx/modules-enabled/ \
&& mkdir -p /usr/lib/nginx/modules \
&& ln -s /etc/nginx/modules /usr/lib/nginx/modules \
&& cd /usr/src/nginx-$NGINX_VERSION \
&& cp objs/*.so /usr/lib/nginx/modules \
&& echo "load_module /usr/lib/nginx/modules/ngx_http_brotli_filter_module.so;" >> /etc/nginx/modules-enabled/brotli.conf \
&& echo "load_module /usr/lib/nginx/modules/ngx_http_brotli_static_module.so;" >> /etc/nginx/modules-enabled/brotli.conf \
&& ln -s /usr/lib/nginx/modules /etc/nginx/modules \
&& strip /usr/sbin/nginx* \
&& mv /usr/bin/envsubst /tmp/ \
&& runDeps="$( \
scanelf --needed --nobanner /usr/sbin/nginx /usr/lib/nginx/modules/*.so /tmp/envsubst \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --no-cache --virtual .nginx-rundeps tzdata $runDeps \
&& mv /tmp/envsubst /usr/local/bin/ \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
&& mkdir -p /app/ \
&& touch /app/index.html \
&& echo "<h1>It Works!</h1>" >> /app/index.html
# hadolint ignore=DL3022
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
RUN go get github.com/Kagami/go-avif \
&& cd /root/go/src/github.com/Kagami/go-avif \
&& make all \
&& mv /root/go/bin/avif /usr/local/bin/avif
STOPSIGNAL SIGQUIT
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
RUN curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash > /root/.git-completion.bash \
&& curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh > /root/.git-prompt.sh \
&& curl https://raw.githubusercontent.com/ogham/exa/master/completions/completions.bash > /root/.completions.bash
USER application
RUN curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash > /home/$APPLICATION_USER/.git-completion.bash \
&& curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh > /home/$APPLICATION_USER/.git-prompt.sh \
&& curl https://raw.githubusercontent.com/ogham/exa/master/completions/completions.bash > /home/$APPLICATION_USER/.completions.bash
RUN composer global require perftools/php-profiler && composer clear
COPY user/* /home/$APPLICATION_USER/
RUN echo "source ~/bashconfig.sh" >> ~/.bashrc
USER root
COPY user/* /root/
RUN mkdir -p /opt/php-libs
COPY php/* /opt/php-libs/files/
RUN mv /opt/php-libs/files/opcache-jit.ini "$PHP_INI_DIR/conf.d/docker-php-opcache-jit.ini" \
&& install-php-extensions \
xdebug-^3 \
pcov \
mongodb \
zip \
soap \
gd \
pcntl \
&& docker-php-ext-install ffi \
&& docker-php-ext-enable ffi
RUN mv /opt/php-libs/files/pcov.ini "$PHP_INI_DIR/conf.d/docker-php-pcov.ini" \
&& mkdir /tmp/debug \
&& chmod -R 777 /tmp/debug \
# && mkdir -p /opt/docker/profiler \
# && mv /opt/php-libs/files/xhprof.ini "$PHP_INI_DIR/conf.d/docker-php-ext-xhprof.ini" \
&& echo "ffi.enable=preload" >> "$PHP_INI_DIR/conf.d/docker-php-ffi.ini"
ENV \
COMPOSER_HOME=/home/$APPLICATION_USER/.composer \
POSTFIX_RELAYHOST="[global-mail]:1025" \
PHP_DISPLAY_ERRORS="1" \
PHP_MEMORY_LIMIT="-1" \
TZ=Europe/Berlin
WORKDIR /tmp
ENV PATH=/usr/local/cargo/bin:$PATH
RUN git clone https://github.com/ogham/exa \
&& cd exa \
&& cargo build --release \
&& mv target/release/exa /usr/local/bin/exa \
&& curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin/ \
&& rm -rf /tmp/exa
# hadolint ignore=DL4001
RUN wget https://github.com/dalance/amber/releases/download/v0.5.8/amber-v0.5.8-x86_64-lnx.zip \
&& unzip amber-v0.5.8-x86_64-lnx.zip \
&& rm amber-v0.5.8-x86_64-lnx.zip \
&& mv amb* /usr/local/bin/
COPY entrypoint/entrypoint.sh /entrypoint
COPY entrypoint/scripts /entrypoint.d/
COPY bins/ /usr-bins/
RUN chmod +x /entrypoint.d/*.sh /entrypoint /usr-bins/* \
&& mv /usr-bins/* /usr/local/bin/ \
&& mkdir -p /var/log/supervisord
RUN apk del .build-deps .nginx-rundeps
ENTRYPOINT ["/entrypoint"]
EXPOSE 80 443 9003
WORKDIR /app