<p class="wp-block-paragraph">I spent 2 hours of what it lasts of my life trying to understand what was the problem on installing php’s zmq extension in a docker running alpine as base image. I would like to share my experience here.</p>
<p class="wp-block-paragraph">During morning I would like to write supporting class for integrating zmq into our system and use it from inside containers where services are supposed to run.</p>
<p class="wp-block-paragraph">First I just added to Dockerfile the pecl install command, and expected it works:</p>
<pre class="wp-block-preformatted">FROM php:7-cli-alpine<br>RUN apk add zeromq libzmq<br>RUN pecl install zmq-beta \<br> && docker-php-ext-enable zmq</pre>
<p class="wp-block-paragraph">Image page on Docker Hub specify there should be no problem (rif. <a href="https://hub.docker.com/_/php/" target="_blank" rel="noopener" title="">https://hub.docker.com/_/php/</a> # PECL extensions )</p>
<pre class="wp-block-preformatted">> docker build .</pre>
<p>[blah blah check that worked]</p>
<p class="wp-block-paragraph">checking whether the C compiler works… no
configure: error: in `/tmp/pear/temp/pear-build-defaultuserEhCEfp/zmq-1.1.3′:
configure: error: C compiler cannot create executables
See `config.log’ for more details
</p>
<p class="wp-block-paragraph">and no way to find this config.log :</p>
<p class="wp-block-paragraph">> docker run –rm xxxx ls /tmp/pear/</p>
<p class="wp-block-paragraph">no such file. In fact pecl cleanup its building folder everytime, even if it fails. (why?? or bigger: WHY??)</p>
<p class="wp-block-paragraph">I started with a reduced image, just </p>
<pre class="wp-block-preformatted">FROM php:7-cli-alpine
RUN apk add zeromq libzmq</pre>
<p class="wp-block-paragraph">I ran:</p>
<pre class="wp-block-preformatted">inside_docker> pecl install zmq-beta
you do not have autoconf!
inside_docker> apk add autoconf
...
inside_docker> pecl install zmq-beta </pre>
<p class="wp-block-paragraph">no way, no config.log.</p>
<p class="wp-block-paragraph">I am a bit nervouse, I asked my collegue, a PHP expert … “Sorry, I’m not aware of this completely”. More nervouse. Some food.</p>
<p class="wp-block-paragraph">Tried in my machine, a debian, and pecl install worked.</p>
<p class="wp-block-paragraph">I got source from git (now I follow http://zeromq.org/bindings:php )</p>
<pre class="wp-block-preformatted">inside_docker> git clone git://github.com/mkoppanen/php-zmq.git
...no git command
inside_docker> apk add git
..[repeat again]
inside_docker> cd php-zmq
inside_docker> phpize
... no phpize
inside_docker> apk add phpize
inside_docker> phpize
inside_docker> ./configure
....[blah ...]
check config.log
</pre>
<p class="wp-block-paragraph">And now it exists! but, what?!?</p>
<pre class="wp-block-preformatted">configure:2697: cc -V >&5
cc: error: unrecognized command line option '-V'
cc: fatal error: no input files
compilation terminated.
configure:2708: $? = 1
configure:2697: cc -qversion >&5
cc: error: unrecognized command line option '-qversion'; did you mean '--version'?
cc: fatal error: no input files
compilation terminated.
configure:2708: $? = 1
configure:2728: checking whether the C compiler works
configure:2750: cc conftest.c >&5
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared
collect2: error: ld returned 1 exit status
configure:2754: $? = 1
configure:2792: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
...
</pre>
<p class="wp-block-paragraph">what is -qversion ? it looks wrong … (I wasted some more time checking that)</p>
<p class="wp-block-paragraph">some line above this:</p>
<pre class="wp-block-preformatted">Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-6.4.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 6.4.0' --enable-checking=release --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-cloog-backend --enable-languages=c,c++,objc,java,fortran,ada --disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-system-zlib --with-linker-hash-style=gnu
Thread model: posix
gcc version 6.4.0 (Alpine 6.4.0)
</pre>
<p class="wp-block-paragraph">I decided to compare with the config.log created in my debian machine. I splitted the lines:</p>
<pre class="wp-block-preformatted">../src/configure -v
--with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04'
--with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++
--prefix=/usr
--with-gcc-major-version-only
--program-suffix=-7
--program-prefix=x86_64-linux-gnu-
--enable-shared
--enable-linker-build-id
--libexecdir=/usr/lib
--without-included-gettext
--enable-threads=posix
--libdir=/usr/lib
--enable-nls
--with-sysroot=/
--enable-clocale=gnu
--enable-libstdcxx-debug
--enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new
--enable-gnu-unique-object
--disable-vtable-verify
--enable-libmpx --enable-plugin
--enable-default-pie
--with-system-zlib
--with-target-system-zlib
--enable-objc-gc=auto
--enable-multiarch
--disable-werror
--with-arch-32=i686
--with-abi=m64
--with-multilib-list=m32,m64,mx32
--enable-multilib
--with-tune=generic
--enable-offload-targets=nvptx-none
--without-cuda-driver
--enable-checking=release
--build=x86_64-linux-gnu
--host=x86_64-linux-gnu
--target=x86_64-linux-gnu
/home/buildozer/aports/main/gcc/src/gcc-6.4.0/configure --prefix=/usr
--mandir=/usr/share/man
--infodir=/usr/share/info
--build=x86_64-alpine-linux-musl
--host=x86_64-alpine-linux-musl
--target=x86_64-alpine-linux-musl
--with-pkgversion='Alpine 6.4.0'
--enable-checking=release
--disable-fixed-point
--disable-libstdcxx-pch
--disable-multilib
--disable-nls
--disable-werror
--disable-symvers
--enable-__cxa_atexit
--enable-default-pie
--enable-cloog-backend
--enable-languages=c,c++,objc,java,fortran,ada
--disable-libssp
--disable-libmpx
--disable-libmudflap
--disable-libsanitizer
--enable-shared
--enable-threads
--enable-tls
--with-system-zlib
--with-linker-hash-style=gnu
</pre>
<p class="wp-block-paragraph">I asked the internet: what is multilib? is not possible to have m32 on alpine and blah … ( <a href="https://stackoverflow.com/questions/40539592/how-to-compile-a-32bit-hello-world-on-alpine" target="_blank" rel="noopener" title="">https://stackoverflow.com/questions/40539592/how-to-compile-a-32bit-hello-world-on-alpine</a> ). Fuck. I just want something like:</p>
<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">inside_docker> apk add build-base</p>
</blockquote>
<p class="wp-block-paragraph">and then … pecl:</p>
<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">inside_docker> pecl install zmq-beta</p>
</blockquote>
<p class="wp-block-paragraph">It run! It works. So my Dockerfile:</p>
<pre class="wp-block-preformatted">FROM php:7-cli-alpine
RUN apk add autoconf gcc libzmq zeromq-dev zeromq coreutils build-base
RUN pecl install zmq-beta \
&& docker-php-ext-enable zmq
</pre>
<p class="wp-block-paragraph">That’s all. Now I can start the real work.</p>
<h2 class="wp-block-heading">Docker Image</h2>
<p class="wp-block-paragraph">The Dockerfile for it is on <a href="https://github.com/starsellersworld/reactphpzeromq">https://github.com/starsellersworld/reactphpzeromq</a></p>
I spent 2 hours of what it lasts of my life trying to understand what was the problem on installing php’s zmq extension in a docker running alpine as base image. I would like to share my experience here.
During morning I would like to write supporting class for integrating zmq into our system and use it from inside containers where services are supposed to run.
First I just added to Dockerfile the pecl install command, and expected it works:
FROM php:7-cli-alpine
RUN apk add zeromq libzmq
RUN pecl install zmq-beta \
&& docker-php-ext-enable zmq
Image page on Docker Hub specify there should be no problem (rif. https://hub.docker.com/_/php/ # PECL extensions )
> docker build .
[blah blah check that worked]
checking whether the C compiler works… no
configure: error: in `/tmp/pear/temp/pear-build-defaultuserEhCEfp/zmq-1.1.3′:
configure: error: C compiler cannot create executables
See `config.log’ for more details
and no way to find this config.log :
> docker run –rm xxxx ls /tmp/pear/
no such file. In fact pecl cleanup its building folder everytime, even if it fails. (why?? or bigger: WHY??)
I started with a reduced image, just
FROM php:7-cli-alpine
RUN apk add zeromq libzmq
I ran:
inside_docker> pecl install zmq-beta
you do not have autoconf!
inside_docker> apk add autoconf
...
inside_docker> pecl install zmq-beta
no way, no config.log.
I am a bit nervouse, I asked my collegue, a PHP expert … “Sorry, I’m not aware of this completely”. More nervouse. Some food.
Tried in my machine, a debian, and pecl install worked.
I got source from git (now I follow http://zeromq.org/bindings:php )
inside_docker> git clone git://github.com/mkoppanen/php-zmq.git
...no git command
inside_docker> apk add git
..[repeat again]
inside_docker> cd php-zmq
inside_docker> phpize
... no phpize
inside_docker> apk add phpize
inside_docker> phpize
inside_docker> ./configure
....[blah ...]
check config.log
And now it exists! but, what?!?
configure:2697: cc -V >&5
cc: error: unrecognized command line option '-V'
cc: fatal error: no input files
compilation terminated.
configure:2708: $? = 1
configure:2697: cc -qversion >&5
cc: error: unrecognized command line option '-qversion'; did you mean '--version'?
cc: fatal error: no input files
compilation terminated.
configure:2708: $? = 1
configure:2728: checking whether the C compiler works
configure:2750: cc conftest.c >&5
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared
collect2: error: ld returned 1 exit status
configure:2754: $? = 1
configure:2792: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
...
what is -qversion ? it looks wrong … (I wasted some more time checking that)
some line above this:
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-6.4.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 6.4.0' --enable-checking=release --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-cloog-backend --enable-languages=c,c++,objc,java,fortran,ada --disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-system-zlib --with-linker-hash-style=gnu
Thread model: posix
gcc version 6.4.0 (Alpine 6.4.0)
I decided to compare with the config.log created in my debian machine. I splitted the lines:
../src/configure -v
--with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04'
--with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++
--prefix=/usr
--with-gcc-major-version-only
--program-suffix=-7
--program-prefix=x86_64-linux-gnu-
--enable-shared
--enable-linker-build-id
--libexecdir=/usr/lib
--without-included-gettext
--enable-threads=posix
--libdir=/usr/lib
--enable-nls
--with-sysroot=/
--enable-clocale=gnu
--enable-libstdcxx-debug
--enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new
--enable-gnu-unique-object
--disable-vtable-verify
--enable-libmpx --enable-plugin
--enable-default-pie
--with-system-zlib
--with-target-system-zlib
--enable-objc-gc=auto
--enable-multiarch
--disable-werror
--with-arch-32=i686
--with-abi=m64
--with-multilib-list=m32,m64,mx32
--enable-multilib
--with-tune=generic
--enable-offload-targets=nvptx-none
--without-cuda-driver
--enable-checking=release
--build=x86_64-linux-gnu
--host=x86_64-linux-gnu
--target=x86_64-linux-gnu
/home/buildozer/aports/main/gcc/src/gcc-6.4.0/configure --prefix=/usr
--mandir=/usr/share/man
--infodir=/usr/share/info
--build=x86_64-alpine-linux-musl
--host=x86_64-alpine-linux-musl
--target=x86_64-alpine-linux-musl
--with-pkgversion='Alpine 6.4.0'
--enable-checking=release
--disable-fixed-point
--disable-libstdcxx-pch
--disable-multilib
--disable-nls
--disable-werror
--disable-symvers
--enable-__cxa_atexit
--enable-default-pie
--enable-cloog-backend
--enable-languages=c,c++,objc,java,fortran,ada
--disable-libssp
--disable-libmpx
--disable-libmudflap
--disable-libsanitizer
--enable-shared
--enable-threads
--enable-tls
--with-system-zlib
--with-linker-hash-style=gnu
I asked the internet: what is multilib? is not possible to have m32 on alpine and blah … ( https://stackoverflow.com/questions/40539592/how-to-compile-a-32bit-hello-world-on-alpine ). Fuck. I just want something like:
inside_docker> apk add build-base
and then … pecl:
inside_docker> pecl install zmq-beta
It run! It works. So my Dockerfile:
FROM php:7-cli-alpine
RUN apk add autoconf gcc libzmq zeromq-dev zeromq coreutils build-base
RUN pecl install zmq-beta \
&& docker-php-ext-enable zmq
That’s all. Now I can start the real work.
Docker Image
The Dockerfile for it is on https://github.com/starsellersworld/reactphpzeromq