(I wrote a question on stackoverflow about it, but I guess it fits more here.)
My Dockerfile:
FROM php:5.6-apache
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php -r "if (hash_file('SHA384', 'composer-setup.php') === '070854512ef404f16bac87071a6db9fd9721da1684cd4589b1196c3faf71b9a2682e2311b36a5079825e155ac7ce150d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php && \
php -r "unlink('composer-setup.php');"
RUN apt-get update && \
apt-get install vim git -y
RUN docker-php-ext-install mysqlnd pdo pdo_mysql
RUN cd / && \
git clone --depth=1 git://github.com/phalcon/cphalcon.git && \
cd cphalcon/build && \
./install
RUN echo "extension=phalcon.so" > /usr/local/etc/php/conf.d/phalcon.ini
RUN a2enmod rewrite
My docker-compose.yml:
phlaconapp:
hostname: phaclonapp
dockerfile: Dockerfile
build: ./
ports:
- "1080:80"
- "1043:433"
environment:
TERM: xterm-color
ENVIRONMENT: dev
volumes:
- ./:/var/www/html/
links:
- mysql
mysql:
image: mysql:5.6
volumes:
- ./docker/mysql.d:/etc/mysql/conf.d
ports: ["3306:3306"]
environment:
MYSQL_ROOT_PASSWORD: 'root'
Yet when running docker-compose build I get:
\mysql uses an image, skipping
Building phlaconapp
Step 1 : FROM php:5.6-apache
---> 2dd2b6f11998
Step 2 : RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php -r "if (hash_file('SHA384', 'composer-setup.php') === '070854512ef404f16bac87071a6db9fd9721da1684cd4589b1196c3faf71b9a2682e2311b36a5079825e155ac7ce150d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && php composer-setup.php && php -r "unlink('composer-setup.php');"
---> Using cache
---> be0059709c8b
Step 3 : RUN apt-get update && apt-get install vim git -y
---> Using cache
---> 64cc739633c9
Step 4 : RUN docker-php-ext-install mysqlnd pdo pdo_mysql
---> Running in 8587aeb52c5b
+ cd /usr/src/php/ext/mysqlnd
+ phpize
Cannot find config.m4.
Make sure that you run '/usr/local/bin/phpize' in the top level source directory of the module
ERROR: Service 'phlaconapp' failed to build: The command '/bin/sh -c docker-php-ext-install mysqlnd pdo pdo_mysql' returned a non-zero code: 1
How am I supposed to install extension with docker-php-ext-install?
We were hit by this today too. We've tracked it down to https://github.com/docker-library/php/commit/e3db777ec694977683c69d641ec2dcdc3bf41ce3.
Basically docker-php-ext-install now cleans up dependencies before exiting. Meaning that you can't chain a docker-php-ext-configure anymore, as docker-php-ext-install is not handling the dependencies. I believe this is a bug. docker-php-ext-configure should install the dependencies too.
Or how is this suppose to work now @tianon @ncopa?
I now see that you aren't using any configure step, but I think its related at least :)
My current workaround is not looking very nice:
RUN ...
&& apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS \
&& docker-php-ext-configure gd --with-png-dir=/usr/include --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& apk del .phpize-deps \
Note that apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS \ is needed after each docker-php-ext-install call as that script removes the dependencies...
I also just noticed that this workaround is needed for pecl installs too. What's the plan for handling that?
Our problem will get fixed by #239
yup so @k0pernikus maybe you can close this issue? 馃槈
.
Seems to be a bug in phpize (https://bugs.php.net/bug.php?id=53571).
I added the following to docker-php-ext-configure:
/usr/local/bin # diff -u docker-php-ext-configure.bak docker-php-ext-configure
--- docker-php-ext-configure.bak
+++ docker-php-ext-configure
@@ -54,5 +54,6 @@
set -x
cd "$ext"
+[[ ! -f "config.m4" && -f "config0.m4" ]] && mv config0.m4 config.m4
phpize
./configure "$@"
Another Quick-And-Dirty solution for "phpize, Cannot find config.m4.":
RUN docker-php-ext-install zlib; exit 0
RUN cp /usr/src/php/ext/zlib/config0.m4 /usr/src/php/ext/zlib/config.m4
RUN docker-php-ext-install zlib
Any ideas when this will be fixed? Still having this issue with latest php:7.2-rc-fpm-alpine.
For me it failed couple times trying to install other extensions like zlib openssl, but these were already included in the base image when I ran phpinfo. Also I'm using @michaellopez workaround and it worked just fine. on php:7.1.7-fpm-alpine
Dockerfile
FROM php:7.1.7-fpm-alpine
WORKDIR /usr/share/nginx/html
RUN apk --no-cache add --virtual .build-deps $PHPIZE_DEPS \
&& apk --no-cache add --virtual .ext-deps libmcrypt-dev freetype-dev \
libjpeg-turbo-dev libpng-dev libxml2-dev msmtp postgresql-dev \
&& docker-php-source extract \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ \
--with-png-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd mcrypt mysqli pdo pdo_mysql pdo_pgsql pgsql zip ftp opcache \
&& pecl install mongodb redis xdebug \
&& docker-php-ext-enable mongodb \
&& docker-php-ext-enable redis \
&& docker-php-ext-enable xdebug \
&& docker-php-source delete \
&& apk del .build-deps \
# composer taken from (https://github.com/geshan/docker-php-composer-alpine)
&& apk --no-cache add curl git openssh \
&& curl -sSL https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
I came across this on php:7.1.10-apache while trying to install the zlib extension. The fix that @allofmex suggested (https://github.com/docker-library/php/issues/233#issuecomment-288727629) worked for me.
Just ran into this issue trying to install OpenSSL on php:7-fpm-alpine. I'm not running docker-php-ext-configure explicitly, but it's executed by docker-php-ext-install.
@estahn fix works perfectly, I think he's correct that the cause is a 7 year old bug in phpize.
@chrBrd, openssl and a few other modules are built with php and do not require docker-php-ext* scripts: https://github.com/docker-library/php/blob/d8d798be28c49ced47d772aa899c0a1febabdba3/7.1/alpine3.4/fpm/Dockerfile#L116-L132
You can even verify that it is available:
$ docker run --rm php:7-fpm-alpine php -i | grep -i ssl
Configure Command => './configure' '--build=x86_64-linux-musl' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--disable-cgi' '--enable-ftp' '--enable-mbstring' '--enable-mysqlnd' '--with-curl' '--with-libedit' '--with-openssl' '--with-zlib' '--with-pcre-regex=/usr' '--enable-fpm' '--with-fpm-user=www-data' '--with-fpm-group=www-data' 'build_alias=x86_64-linux-musl'
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, tls, tlsv1.0, tlsv1.1, tlsv1.2
SSL => Yes
SSL Version => OpenSSL/1.0.2k
core SSL => supported
extended SSL => supported
openssl
OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.0.2k 26 Jan 2017
OpenSSL Header Version => OpenSSL 1.0.2k 26 Jan 2017
Openssl default config => /etc/ssl/openssl.cnf
openssl.cafile => no value => no value
openssl.capath => no value => no value
Native OpenSSL support => enabled
Thanks for letting me know @yosifikit. Sorry I didn't notice that myself, especially since I'm sitting here with the Dockerfile open in another tab.
Closing, since https://github.com/docker-library/php/pull/239 solved the original issue described in this report. :+1:
Still doesn't work.
sqlite3 has config0.m4 so phpize doesn't manage to build the extension.
How it supposed to work?
@o10g see https://github.com/docker-library/php/issues/574:
$ docker pull php:7
7: Pulling from library/php
Digest: sha256:560fa3ea47759beb28ed786eafdbc2d0e7091fc4179480dab72241b4972c7c4e
Status: Image is up to date for php:7
$ docker run -it --rm php:7 bash
root@8193d9dd2e8b:/# php -i | grep -i sqlite
PDO drivers => sqlite
pdo_sqlite
PDO Driver for SQLite 3.x => enabled
SQLite Library => 3.20.1
sqlite3
SQLite3 support => enabled
SQLite3 module version => 7.2.2
SQLite Library => 3.20.1
sqlite3.extension_dir => no value => no value
Removing the docker-php-ext-install zlib from the docker fixed for me
Still affecting php:7.4-fpm-alpine but skipping installation of extensions that are already included in the image seems to avoid the issue.
Removing docker-php-ext-install zlib fix the issue with php:7.3-fpm-alpine.
If you take a look here, the extension is already installed.
Most helpful comment
Another Quick-And-Dirty solution for "phpize, Cannot find config.m4.":
First we try to install your extension, it will fail here so force exit code 0 to keep Dockerfile processing.
We do this to have the extension files downloaded for step 2
RUN docker-php-ext-install zlib; exit 0
Now we rename the in step 1 downloaded file to desired filename
RUN cp /usr/src/php/ext/zlib/config0.m4 /usr/src/php/ext/zlib/config.m4
And try to install extension again, this time it works
RUN docker-php-ext-install zlib