|
| 1 | +# |
| 2 | +# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh" |
| 3 | +# |
| 4 | +# PLEASE DO NOT EDIT IT DIRECTLY. |
| 5 | +# |
| 6 | + |
| 7 | +FROM alpine:3.9 |
| 8 | + |
| 9 | +# dependencies required for running "phpize" |
| 10 | +# these get automatically installed and removed by "docker-php-ext-*" (unless they're already installed) |
| 11 | +ENV PHPIZE_DEPS \ |
| 12 | + autoconf \ |
| 13 | + dpkg-dev dpkg \ |
| 14 | + file \ |
| 15 | + g++ \ |
| 16 | + gcc \ |
| 17 | + libc-dev \ |
| 18 | + make \ |
| 19 | + pkgconf \ |
| 20 | + re2c |
| 21 | + |
| 22 | +# persistent / runtime deps |
| 23 | +RUN apk add --no-cache \ |
| 24 | + ca-certificates \ |
| 25 | + curl \ |
| 26 | + tar \ |
| 27 | + xz \ |
| 28 | +# https://github.com/docker-library/php/issues/494 |
| 29 | + openssl |
| 30 | + |
| 31 | +# ensure www-data user exists |
| 32 | +RUN set -x \ |
| 33 | + && addgroup -g 82 -S www-data \ |
| 34 | + && adduser -u 82 -D -S -G www-data www-data |
| 35 | +# 82 is the standard uid/gid for "www-data" in Alpine |
| 36 | +# https://git.alpinelinux.org/aports/tree/main/apache2/apache2.pre-install?h=3.9-stable |
| 37 | +# https://git.alpinelinux.org/aports/tree/main/lighttpd/lighttpd.pre-install?h=3.9-stable |
| 38 | +# https://git.alpinelinux.org/aports/tree/main/nginx/nginx.pre-install?h=3.9-stable |
| 39 | + |
| 40 | +ENV PHP_INI_DIR /usr/local/etc/php |
| 41 | +RUN set -eux; \ |
| 42 | + mkdir -p "$PHP_INI_DIR/conf.d"; \ |
| 43 | +# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743) |
| 44 | + [ ! -d /var/www/html ]; \ |
| 45 | + mkdir -p /var/www/html; \ |
| 46 | + chown www-data:www-data /var/www/html; \ |
| 47 | + chmod 777 /var/www/html |
| 48 | + |
| 49 | +##<autogenerated>## |
| 50 | +##</autogenerated>## |
| 51 | + |
| 52 | +# Apply stack smash protection to functions using local buffers and alloca() |
| 53 | +# Make PHP's main executable position-independent (improves ASLR security mechanism, and has no performance impact on x86_64) |
| 54 | +# Enable optimization (-O2) |
| 55 | +# Enable linker optimization (this sorts the hash buckets to improve cache locality, and is non-default) |
| 56 | +# 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) |
| 57 | +# https://github.com/docker-library/php/issues/272 |
| 58 | +ENV PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2" |
| 59 | +ENV PHP_CPPFLAGS="$PHP_CFLAGS" |
| 60 | +ENV PHP_LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie" |
| 61 | + |
| 62 | +ENV GPG_KEYS 42670A7FE4D0441C8E4632349E4FDC074A4EF02D 5A52880781F755608BF815FC910DEB46F53EA312 |
| 63 | + |
| 64 | +ENV PHP_VERSION 7.4.0alpha1 |
| 65 | +ENV PHP_URL="https://downloads.php.net/~derick/php-7.4.0alpha1.tar.xz" PHP_ASC_URL="https://downloads.php.net/~derick/php-7.4.0alpha1.tar.xz.asc" |
| 66 | +ENV PHP_SHA256="378400b6eced6e358f5db750413a7f9959517b0daef6580b16d640190b7dc364" PHP_MD5="" |
| 67 | + |
| 68 | +RUN set -xe; \ |
| 69 | + \ |
| 70 | + apk add --no-cache --virtual .fetch-deps \ |
| 71 | + gnupg \ |
| 72 | + wget \ |
| 73 | + ; \ |
| 74 | + \ |
| 75 | + mkdir -p /usr/src; \ |
| 76 | + cd /usr/src; \ |
| 77 | + \ |
| 78 | + wget -O php.tar.xz "$PHP_URL"; \ |
| 79 | + \ |
| 80 | + if [ -n "$PHP_SHA256" ]; then \ |
| 81 | + echo "$PHP_SHA256 *php.tar.xz" | sha256sum -c -; \ |
| 82 | + fi; \ |
| 83 | + if [ -n "$PHP_MD5" ]; then \ |
| 84 | + echo "$PHP_MD5 *php.tar.xz" | md5sum -c -; \ |
| 85 | + fi; \ |
| 86 | + \ |
| 87 | + if [ -n "$PHP_ASC_URL" ]; then \ |
| 88 | + wget -O php.tar.xz.asc "$PHP_ASC_URL"; \ |
| 89 | + export GNUPGHOME="$(mktemp -d)"; \ |
| 90 | + for key in $GPG_KEYS; do \ |
| 91 | + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ |
| 92 | + done; \ |
| 93 | + gpg --batch --verify php.tar.xz.asc php.tar.xz; \ |
| 94 | + command -v gpgconf > /dev/null && gpgconf --kill all; \ |
| 95 | + rm -rf "$GNUPGHOME"; \ |
| 96 | + fi; \ |
| 97 | + \ |
| 98 | + apk del --no-network .fetch-deps |
| 99 | + |
| 100 | +COPY docker-php-source /usr/local/bin/ |
| 101 | + |
| 102 | +RUN set -xe \ |
| 103 | + && apk add --no-cache --virtual .build-deps \ |
| 104 | + $PHPIZE_DEPS \ |
| 105 | + argon2-dev \ |
| 106 | + coreutils \ |
| 107 | + curl-dev \ |
| 108 | + libedit-dev \ |
| 109 | + libsodium-dev \ |
| 110 | + libxml2-dev \ |
| 111 | + openssl-dev \ |
| 112 | + sqlite-dev \ |
| 113 | + \ |
| 114 | + && export CFLAGS="$PHP_CFLAGS" \ |
| 115 | + CPPFLAGS="$PHP_CPPFLAGS" \ |
| 116 | + LDFLAGS="$PHP_LDFLAGS" \ |
| 117 | + && docker-php-source extract \ |
| 118 | + && cd /usr/src/php \ |
| 119 | + && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ |
| 120 | + && ./configure \ |
| 121 | + --build="$gnuArch" \ |
| 122 | + --with-config-file-path="$PHP_INI_DIR" \ |
| 123 | + --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ |
| 124 | + \ |
| 125 | +# make sure invalid --configure-flags are fatal errors intead of just warnings |
| 126 | + --enable-option-checking=fatal \ |
| 127 | + \ |
| 128 | +# https://github.com/docker-library/php/issues/439 |
| 129 | + --with-mhash \ |
| 130 | + \ |
| 131 | +# --enable-ftp is included here because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236) |
| 132 | + --enable-ftp \ |
| 133 | +# --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) |
| 134 | + --enable-mbstring \ |
| 135 | +# --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) |
| 136 | + --enable-mysqlnd \ |
| 137 | +# https://wiki.php.net/rfc/argon2_password_hash (7.2+) |
| 138 | + --with-password-argon2 \ |
| 139 | +# https://wiki.php.net/rfc/libsodium |
| 140 | + --with-sodium=shared \ |
| 141 | + \ |
| 142 | + --with-curl \ |
| 143 | + --with-libedit \ |
| 144 | + --with-openssl \ |
| 145 | + --with-zlib \ |
| 146 | + \ |
| 147 | +# bundled pcre does not support JIT on s390x |
| 148 | +# https://manpages.debian.org/stretch/libpcre3-dev/pcrejit.3.en.html#AVAILABILITY_OF_JIT_SUPPORT |
| 149 | + $(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \ |
| 150 | + \ |
| 151 | + $PHP_EXTRA_CONFIGURE_ARGS \ |
| 152 | + && make -j "$(nproc)" \ |
| 153 | + && find -type f -name '*.a' -delete \ |
| 154 | + && make install \ |
| 155 | + && { find /usr/local/bin /usr/local/sbin -type f -perm +0111 -exec strip --strip-all '{}' + || true; } \ |
| 156 | + && make clean \ |
| 157 | + \ |
| 158 | +# https://github.com/docker-library/php/issues/692 (copy default example "php.ini" files somewhere easily discoverable) |
| 159 | + && cp -v php.ini-* "$PHP_INI_DIR/" \ |
| 160 | + \ |
| 161 | + && cd / \ |
| 162 | + && docker-php-source delete \ |
| 163 | + \ |
| 164 | + && runDeps="$( \ |
| 165 | + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ |
| 166 | + | tr ',' '\n' \ |
| 167 | + | sort -u \ |
| 168 | + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ |
| 169 | + )" \ |
| 170 | + && apk add --no-cache $runDeps \ |
| 171 | + \ |
| 172 | + && apk del --no-network .build-deps \ |
| 173 | + \ |
| 174 | +# https://github.com/docker-library/php/issues/443 |
| 175 | + && pecl update-channels \ |
| 176 | + && rm -rf /tmp/pear ~/.pearrc |
| 177 | + |
| 178 | +COPY docker-php-ext-* docker-php-entrypoint /usr/local/bin/ |
| 179 | + |
| 180 | +# sodium was built as a shared module (so that it can be replaced later if so desired), so let's enable it too (https://github.com/docker-library/php/issues/598) |
| 181 | +RUN docker-php-ext-enable sodium |
| 182 | + |
| 183 | +ENTRYPOINT ["docker-php-entrypoint"] |
| 184 | +##<autogenerated>## |
| 185 | +CMD ["php", "-a"] |
| 186 | +##</autogenerated>## |
0 commit comments