1+ #
2+ # NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
3+ #
4+ # PLEASE DO NOT EDIT IT DIRECTLY.
5+ #
6+ FROM php:5.6.40-fpm AS php-source
7+ FROM debian:bullseye-slim
8+
9+ RUN sed -i 's|http://deb.debian.org|http://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list && \
10+ sed -i 's|http://security.debian.org|http://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list && \
11+ apt-get update
12+
13+ # prevent Debian's PHP packages from being installed
14+ # https://github.com/docker-library/php/pull/542
15+ RUN set -eux; \
16+ { \
17+ echo 'Package: php*' ; \
18+ echo 'Pin: release *' ; \
19+ echo 'Pin-Priority: -1' ; \
20+ } > /etc/apt/preferences.d/no-debian-php
21+
22+ # dependencies required for running "phpize"
23+ # (see persistent deps below)
24+ ENV PHPIZE_DEPS \
25+ autoconf \
26+ dpkg-dev \
27+ file \
28+ g++ \
29+ gcc \
30+ libc-dev \
31+ make \
32+ pkg-config \
33+ re2c
34+
35+ # persistent / runtime deps
36+ RUN apt-get update && apt-get install -y \
37+ $PHPIZE_DEPS \
38+ ca-certificates \
39+ curl \
40+ xz-utils \
41+ zlib1g-dev \
42+ --no-install-recommends && rm -r /var/lib/apt/lists/*
43+
44+ ENV PHP_INI_DIR /usr/local/etc/php
45+ RUN mkdir -p $PHP_INI_DIR/conf.d
46+
47+ # #<autogenerated>##
48+ ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
49+ # #</autogenerated>##
50+
51+ # Apply stack smash protection to functions using local buffers and alloca()
52+ # Make PHP's main executable position-independent (improves ASLR security mechanism, and has no performance impact on x86_64)
53+ # Enable optimization (-O2)
54+ # Enable linker optimization (this sorts the hash buckets to improve cache locality, and is non-default)
55+ # Adds GNU HASH segments to generated executables (this is used if present, and is much faster than sysv hash; in this configuration, sysv hash is also generated)
56+ # https://github.com/docker-library/php/issues/272
57+ ENV PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2"
58+ ENV PHP_CPPFLAGS="$PHP_CFLAGS"
59+ ENV PHP_LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie"
60+
61+ ENV GPG_KEYS 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3
62+
63+ ENV PHP_VERSION 5.6.40
64+ ENV PHP_URL="https://secure.php.net/get/php-5.6.40.tar.xz/from/this/mirror" PHP_ASC_URL="https://secure.php.net/get/php-5.6.40.tar.xz.asc/from/this/mirror"
65+ ENV PHP_SHA256="1369a51eee3995d7fbd1c5342e5cc917760e276d561595b6052b21ace2656d1c" PHP_MD5=""
66+
67+ RUN set -xe; \
68+ \
69+ fetchDeps=' \
70+ wget \
71+ ' ; \
72+ if ! command -v gpg > /dev/null; then \
73+ fetchDeps="$fetchDeps \
74+ dirmngr \
75+ gnupg \
76+ " ; \
77+ fi; \
78+ apt-get update; \
79+ apt-get install -y --no-install-recommends $fetchDeps; \
80+ rm -rf /var/lib/apt/lists/*; \
81+ \
82+ mkdir -p /usr/src; \
83+ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps
84+
85+ # COPY docker-php-source /usr/local/bin/
86+ COPY ./data/php-5.6.40.tar.xz /usr/src/php.tar.xz
87+ COPY --from=php-source /usr/local/bin/docker-php-source /usr/local/bin/
88+
89+
90+ ENV OPENSSL_PREFIX=/usr/local/openssl
91+ ENV CURL_PREFIX=/usr/local/curl
92+ ENV LD_LIBRARY_PATH=/usr/local/openssl/lib:$LD_LIBRARY_PATH
93+
94+ RUN cd /tmp && \
95+ curl -L -o openssl-1.0.2u.tar.gz https://www.openssl.org/source/openssl-1.0.2u.tar.gz && \
96+ tar -xzf openssl-1.0.2u.tar.gz && \
97+ cd openssl-1.0.2u && \
98+ ./config --prefix=$OPENSSL_PREFIX --openssldir=$OPENSSL_PREFIX shared zlib && \
99+ make && \
100+ make install && \
101+ cd / && \
102+ rm -rf /tmp/openssl-1.0.2u*
103+
104+ RUN echo '/usr/local/ssl/lib' > /etc/ld.so.conf.d/openssl.conf && \
105+ ldconfig /usr/local/openssl/lib
106+
107+
108+ RUN set -eux; \
109+ cd /tmp; \
110+ curl -L -o /tmp/curl-8.4.0.tar.gz https://curl.se/download/curl-8.4.0.tar.gz; \
111+ tar -xzf curl-8.4.0.tar.gz; \
112+ cd curl-8.4.0; \
113+ ./configure \
114+ --prefix=$CURL_PREFIX \
115+ --with-openssl=$OPENSSL_PREFIX \
116+ --enable-shared \
117+ --disable-static \
118+ --with-zlib \
119+ --enable-symbol-hiding\
120+ --enable-optimize; \
121+ make -j$(nproc); \
122+ make install; \
123+ cd /tmp; \
124+ rm -rf curl-8.4.0*; \
125+ echo "$CURL_PREFIX/lib" > /etc/ld.so.conf.d/curl.conf; \
126+ ldconfig;
127+
128+ RUN set -eux; \
129+ \
130+ savedAptMark="$(apt-mark showmanual)" ; \
131+ apt-get update; \
132+ apt-get install -y --no-install-recommends \
133+ libcurl4-openssl-dev \
134+ libedit-dev \
135+ libsqlite3-dev \
136+ libxml2-dev \
137+ ${PHP_EXTRA_BUILD_DEPS:-} \
138+ ; \
139+ rm -rf /var/lib/apt/lists/*; \
140+ \
141+ export \
142+ CFLAGS="$PHP_CFLAGS" \
143+ CPPFLAGS="$PHP_CPPFLAGS" \
144+ LDFLAGS="$PHP_LDFLAGS" \
145+ ; \
146+ docker-php-source extract; \
147+ cd /usr/src/php; \
148+ gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ; \
149+ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)" ; \
150+ # https://bugs.php.net/bug.php?id=74125
151+ if [ ! -d /usr/include/curl ]; then \
152+ ln -sT "/usr/include/$debMultiarch/curl" /usr/local/include/curl; \
153+ fi; \
154+ ./configure \
155+ --enable-fpm \
156+ --with-fpm-user=www-data \
157+ --with-fpm-group=www-data \
158+ --disable-cgi \
159+ --with-openssl=/usr/local/openssl \
160+ --with-curl=/usr/local/curl \
161+ --with-zlib \
162+ --enable-mbstring \
163+ --enable-ftp \
164+ --enable-mysqlnd \
165+ --with-config-file-path=/usr/local/etc/php \
166+ --with-config-file-scan-dir=/usr/local/etc/php/conf.d \
167+ ;\
168+ make -j "$(nproc)" ; \
169+ make install; \
170+ find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \
171+ make clean; \
172+ \
173+ # https://github.com/docker-library/php/issues/692 (copy default example "php.ini" files somewhere easily discoverable)
174+ cp -v php.ini-* "$PHP_INI_DIR/" ; \
175+ \
176+ cd /; \
177+ docker-php-source delete; \
178+ \
179+ # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
180+ apt-mark auto '.*' > /dev/null; \
181+ [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
182+ find /usr/local -type f -executable -exec ldd '{}' ';' \
183+ | awk '/=>/ { print $(NF-1) }' \
184+ | sort -u \
185+ | xargs -r dpkg-query --search \
186+ | cut -d: -f1 \
187+ | sort -u \
188+ | xargs -r apt-mark manual \
189+ ; \
190+ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
191+ \
192+ php --version; \
193+ \
194+ # https://github.com/docker-library/php/issues/443
195+ pecl update-channels; \
196+ rm -rf /tmp/pear ~/.pearrc
197+
198+
199+ COPY --from=php-source /usr/local/bin/docker-php-ext-* /usr/local/bin/
200+ COPY --from=php-source /usr/local/bin/docker-php-entrypoint /usr/local/bin/
201+
202+
203+ RUN set -ex \
204+ && cd /usr/local/etc \
205+ && if [ -d php-fpm.d ]; then \
206+ # for some reason, upstream's php-fpm.conf.default has "include=NONE/etc/php-fpm.d/*.conf"
207+ sed 's!=NONE/!=!g' php-fpm.conf.default | tee php-fpm.conf > /dev/null; \
208+ cp php-fpm.d/www.conf.default php-fpm.d/www.conf; \
209+ else \
210+ # PHP 5.x doesn't use "include=" by default, so we'll create our own simple config that mimics PHP 7+ for consistency
211+ mkdir php-fpm.d; \
212+ cp php-fpm.conf.default php-fpm.d/www.conf; \
213+ { \
214+ echo '[global]' ; \
215+ echo 'include=etc/php-fpm.d/*.conf' ; \
216+ } | tee php-fpm.conf; \
217+ fi \
218+ && { \
219+ echo '[global]' ; \
220+ echo 'error_log = /proc/self/fd/2' ; \
221+ echo; \
222+ echo '[www]' ; \
223+ echo '; if we send this to /proc/self/fd/1, it never appears' ; \
224+ echo 'access.log = /proc/self/fd/2' ; \
225+ echo; \
226+ echo 'clear_env = no' ; \
227+ echo; \
228+ echo '; Ensure worker stdout and stderr are sent to the main error log.' ; \
229+ echo 'catch_workers_output = yes' ; \
230+ } | tee php-fpm.d/docker.conf \
231+ && { \
232+ echo '[global]' ; \
233+ echo 'daemonize = no' ; \
234+ echo; \
235+ echo '[www]' ; \
236+ echo 'listen = 9000' ; \
237+ } | tee php-fpm.d/zz-docker.conf
238+
239+ COPY ./data/php-fpm.ini /etc/supervisor.d/php-fpm.ini
240+ COPY ./data/supervisord.conf /etc/supervisord.conf
241+
242+ RUN apt-get update && \
243+ apt-get install -y supervisor iputils-ping && \
244+ apt-get clean && \
245+ rm -rf /var/lib/apt/lists/* &&\
246+ curl -fsSL -o /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
247+ chmod uga+x /usr/local/bin/install-php-extensions && \
248+ curl -o /tmp/composer-setup.php https://getcomposer.org/installer &&\
249+ php /tmp/composer-setup.php --install-dir=/tmp && \
250+ mv /tmp/composer.phar /usr/bin/composer && \
251+ chmod +x /usr/bin/composer &&\
252+ rm -rf /tmp/composer-setup.php
253+
254+ ENV COMPOSER_HOME=/tmp/.composer
255+
256+ RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
257+
258+ ENTRYPOINT ["supervisord" , "--nodaemon" , "--configuration" , "/etc/supervisord.conf" ]
259+
260+ EXPOSE 9000
261+ WORKDIR /www
0 commit comments