Skip to content

Commit 061a241

Browse files
committed
add dockerfile and resource to repo
1 parent b6d4563 commit 061a241

5 files changed

+463
-0
lines changed

Dockerfile

+182
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
7+
FROM alpine:3.4
8+
9+
# persistent / runtime deps
10+
ENV PHPIZE_DEPS \
11+
autoconf \
12+
file \
13+
g++ \
14+
gcc \
15+
libc-dev \
16+
make \
17+
pkgconf \
18+
re2c
19+
RUN apk add --no-cache --virtual .persistent-deps \
20+
ca-certificates \
21+
curl \
22+
tar \
23+
xz
24+
25+
# ensure www-data user exists
26+
RUN set -x \
27+
&& addgroup -g 82 -S www-data \
28+
&& adduser -u 82 -D -S -G www-data www-data
29+
# 82 is the standard uid/gid for "www-data" in Alpine
30+
# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2
31+
# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2
32+
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
33+
34+
ENV PHP_INI_DIR /usr/local/etc/php
35+
RUN mkdir -p $PHP_INI_DIR/conf.d
36+
37+
##<autogenerated>##
38+
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data
39+
##</autogenerated>##
40+
41+
ENV GPG_KEYS F38252826ACD957EF380D39F2F7956BC5DA04B5D
42+
43+
ENV PHP_VERSION 5.4.45
44+
ENV PHP_URL="https://secure.php.net/get/php-5.4.45.tar.gz/from/this/mirror" PHP_ASC_URL="https://secure.php.net/get/php-5.4.45.tar.gz.asc/from/this/mirror"
45+
ENV PHP_SHA256="" PHP_MD5="ba580e774ed1ab256f22d1fa69a59311"
46+
47+
RUN set -xe; \
48+
\
49+
apk add --no-cache --virtual .fetch-deps \
50+
gnupg \
51+
openssl \
52+
; \
53+
\
54+
mkdir -p /usr/src; \
55+
cd /usr/src; \
56+
\
57+
wget -O php.tar.gz "$PHP_URL"; \
58+
\
59+
if [ -n "$PHP_SHA256" ]; then \
60+
echo "$PHP_SHA256 *php.tar.gz" | sha256sum -c -; \
61+
fi; \
62+
if [ -n "$PHP_MD5" ]; then \
63+
echo "$PHP_MD5 *php.tar.gz" | md5sum -c -; \
64+
fi; \
65+
\
66+
if [ -n "$PHP_ASC_URL" ]; then \
67+
wget -O php.tar.gz.asc "$PHP_ASC_URL"; \
68+
export GNUPGHOME="$(mktemp -d)"; \
69+
for key in $GPG_KEYS; do \
70+
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
71+
done; \
72+
gpg --batch --verify php.tar.gz.asc php.tar.gz; \
73+
rm -r "$GNUPGHOME"; \
74+
fi; \
75+
\
76+
apk del .fetch-deps
77+
78+
COPY docker-php-source /usr/local/bin/
79+
80+
RUN set -xe \
81+
&& apk add --no-cache --virtual .build-deps \
82+
$PHPIZE_DEPS \
83+
curl-dev \
84+
libedit-dev \
85+
libxml2-dev \
86+
openssl-dev \
87+
sqlite-dev \
88+
\
89+
&& docker-php-source extract \
90+
&& cd /usr/src/php \
91+
&& ./configure \
92+
--with-config-file-path="$PHP_INI_DIR" \
93+
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
94+
\
95+
--disable-cgi \
96+
\
97+
# --enable-ftp is included here because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236)
98+
--enable-ftp \
99+
# --enable-mbstring is included here because otherwise there's no way to get pecl to use it properly (see https://github.com/docker-library/php/issues/195)
100+
--enable-mbstring \
101+
# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself)
102+
--enable-mysqlnd \
103+
\
104+
--with-curl \
105+
--with-libedit \
106+
--with-openssl \
107+
--with-zlib \
108+
\
109+
$PHP_EXTRA_CONFIGURE_ARGS \
110+
&& make -j "$(getconf _NPROCESSORS_ONLN)" \
111+
&& make install \
112+
&& { find /usr/local/bin /usr/local/sbin -type f -perm +0111 -exec strip --strip-all '{}' + || true; } \
113+
&& make clean \
114+
&& docker-php-source delete \
115+
\
116+
&& runDeps="$( \
117+
scanelf --needed --nobanner --recursive /usr/local \
118+
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
119+
| sort -u \
120+
| xargs -r apk info --installed \
121+
| sort -u \
122+
)" \
123+
&& apk add --no-cache --virtual .php-rundeps $runDeps \
124+
\
125+
&& apk del .build-deps
126+
127+
COPY docker-php-ext-* /usr/local/bin/
128+
129+
##<autogenerated>##
130+
WORKDIR /var/www/html
131+
132+
RUN set -ex \
133+
&& cd /usr/local/etc \
134+
&& if [ -d php-fpm.d ]; then \
135+
# for some reason, upstream's php-fpm.conf.default has "include=NONE/etc/php-fpm.d/*.conf"
136+
sed 's!=NONE/!=!g' php-fpm.conf.default | tee php-fpm.conf > /dev/null; \
137+
cp php-fpm.d/www.conf.default php-fpm.d/www.conf; \
138+
else \
139+
# PHP 5.x don't use "include=" by default, so we'll create our own simple config that mimics PHP 7+ for consistency
140+
mkdir php-fpm.d; \
141+
cp php-fpm.conf.default php-fpm.d/www.conf; \
142+
{ \
143+
echo '[global]'; \
144+
echo 'include=etc/php-fpm.d/*.conf'; \
145+
} | tee php-fpm.conf; \
146+
fi \
147+
&& { \
148+
echo '[global]'; \
149+
echo 'error_log = /proc/self/fd/2'; \
150+
echo; \
151+
echo '[www]'; \
152+
echo '; if we send this to /proc/self/fd/1, it never appears'; \
153+
echo 'access.log = /proc/self/fd/2'; \
154+
echo; \
155+
echo 'clear_env = no'; \
156+
echo; \
157+
echo '; Ensure worker stdout and stderr are sent to the main error log.'; \
158+
echo 'catch_workers_output = yes'; \
159+
} | tee php-fpm.d/docker.conf \
160+
&& { \
161+
echo '[global]'; \
162+
echo 'daemonize = no'; \
163+
echo; \
164+
echo '[www]'; \
165+
echo 'listen = [::]:9000'; \
166+
} | tee php-fpm.d/zz-docker.conf
167+
168+
EXPOSE 9000
169+
CMD ["php-fpm"]
170+
##</autogenerated>##
171+
172+
RUN docker-php-ext-install mysqli
173+
RUN apk upgrade --update && apk add \
174+
coreutils \
175+
freetype-dev \
176+
libjpeg-turbo-dev \
177+
libltdl \
178+
libmcrypt-dev \
179+
libpng-dev \
180+
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
181+
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
182+
&& docker-php-ext-install -j$(nproc) gd

docker-php-ext-configure

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/sh
2+
set -e
3+
4+
srcExists=
5+
if [ -d /usr/src/php ]; then
6+
srcExists=1
7+
fi
8+
docker-php-source extract
9+
if [ -z "$srcExists" ]; then
10+
touch /usr/src/php/.docker-delete-me
11+
fi
12+
13+
ext="$1"
14+
extDir="/usr/src/php/ext/$ext"
15+
if [ -z "$ext" ] || [ ! -d "$extDir" ]; then
16+
echo >&2 "usage: $0 ext-name [configure flags]"
17+
echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
18+
echo >&2
19+
echo >&2 'Possible values for ext-name:'
20+
find /usr/src/php/ext \
21+
-mindepth 2 \
22+
-maxdepth 2 \
23+
-type f \
24+
-name 'config.m4' \
25+
| xargs -n1 dirname \
26+
| xargs -n1 basename \
27+
| sort \
28+
| xargs
29+
exit 1
30+
fi
31+
shift
32+
33+
pm='unknown'
34+
if [ -e /lib/apk/db/installed ]; then
35+
pm='apk'
36+
fi
37+
38+
if [ "$pm" = 'apk' ]; then
39+
if \
40+
[ -n "$PHPIZE_DEPS" ] \
41+
&& ! apk info --installed .phpize-deps > /dev/null \
42+
&& ! apk info --installed .phpize-deps-configure > /dev/null \
43+
; then
44+
apk add --no-cache --virtual .phpize-deps-configure $PHPIZE_DEPS
45+
fi
46+
fi
47+
48+
set -x
49+
cd "$extDir"
50+
phpize
51+
./configure "$@"

docker-php-ext-enable

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/sh
2+
set -e
3+
4+
cd "$(php -r 'echo ini_get("extension_dir");')"
5+
6+
usage() {
7+
echo "usage: $0 [options] module-name [module-name ...]"
8+
echo " ie: $0 gd mysqli"
9+
echo " $0 pdo pdo_mysql"
10+
echo " $0 --ini-name 0-apc.ini apcu apc"
11+
echo
12+
echo 'Possible values for module-name:'
13+
echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort)
14+
}
15+
16+
opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })"
17+
eval set -- "$opts"
18+
19+
iniName=
20+
while true; do
21+
flag="$1"
22+
shift
23+
case "$flag" in
24+
--help|-h|'-?') usage && exit 0 ;;
25+
--ini-name) iniName="$1" && shift ;;
26+
--) break ;;
27+
*)
28+
{
29+
echo "error: unknown flag: $flag"
30+
usage
31+
} >&2
32+
exit 1
33+
;;
34+
esac
35+
done
36+
37+
modules=
38+
for module; do
39+
if [ -z "$module" ]; then
40+
continue
41+
fi
42+
if [ -f "$module.so" ] && ! [ -f "$module" ]; then
43+
# allow ".so" to be optional
44+
module="$module.so"
45+
fi
46+
if ! [ -f "$module" ]; then
47+
echo >&2 "error: $(readlink -f "$module") does not exist"
48+
echo >&2
49+
usage >&2
50+
exit 1
51+
fi
52+
modules="$modules $module"
53+
done
54+
55+
if [ -z "$modules" ]; then
56+
usage >&2
57+
exit 1
58+
fi
59+
60+
for module in $modules; do
61+
if nm -g "$module" | grep -q ' zend_extension_entry$'; then
62+
# https://wiki.php.net/internals/extensions#loading_zend_extensions
63+
line="zend_extension=$(readlink -f "$module")"
64+
else
65+
line="extension=$module"
66+
fi
67+
68+
ext="$(basename "$module")"
69+
ext="${ext%.*}"
70+
if php -r 'exit(extension_loaded("'"$ext"'") ? 0 : 1);'; then
71+
# this isn't perfect, but it's better than nothing
72+
# (for example, 'opcache.so' presents inside PHP as 'Zend OPcache', not 'opcache')
73+
echo >&2
74+
echo >&2 "warning: $ext ($module) is already loaded!"
75+
echo >&2
76+
continue
77+
fi
78+
79+
ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}"
80+
if ! grep -q "$line" "$ini" 2>/dev/null; then
81+
echo "$line" >> "$ini"
82+
fi
83+
done

0 commit comments

Comments
 (0)