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
hey, docker hub specification says there should be no problem (rif. https://hub.docker.com/_/php/ # PECL extensions )
The message was:
> 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.