Reputation: 1345
I have a Dockerfile
that when used with my docker-compose
commands works fine, I'd like to have this docker container built however as GRPC takes 15 mins to install every time I want to run tests in GitHub Actions
This is what my Dockerfile
currently looks like:
FROM xxx-base:6
RUN pecl install grpc \
&& docker-php-ext-enable grpc \
WORKDIR /application
And I get the following error output:
#5 580.4 g++: fatal error: Killed signal terminated program cc1plus
#5 580.4 compilation terminated.
#5 580.4 make: *** [Makefile:248: src/core/ext/filters/client_channel/lb_policy/xds/cds.lo] Error 1
#5 580.5 ERROR: `make' failed
------
executor failed running [/bin/sh -c sudo pecl install grpc && docker-php-ext-enable grpc WORKDIR /application]: exit code: 1
It's worth mentioning in the base container used here I used pecl
to install imagik
so I know that command at least partially works. This is a base PHP 7.4
container.
Any suggestions, I've seen some other posts referring to the memory limit on the docker build, but I'm not sure what to change
Pastebin full stacktrace: pastebin.com/g7iZ2uRn
Upvotes: 3
Views: 3552
Reputation: 674
To expand on the other answers, installing the PECL package for gRPC attempts to compile the C core library (which also includes a good amount of third-party dependencies). That is done before the extension itself, and is what causes the slow build time. You can test it for yourself if you follow the steps described in the "Build from source" section in the PHP README (https://github.com/grpc/grpc/tree/master/src/php#build-from-source) - you'll notice that building C core library can take a lot of time (>10 minutes), while the extension is built pretty fast (~30 seconds).
I followed the advice in this Github comment (https://github.com/grpc/grpc/issues/34278#issuecomment-1871059454) which applies for Docker images using Alpine:
RUN apk add --no-cache git grpc-cpp grpc-dev $PHPIZE_DEPS && \
GRPC_VERSION=$(apk info grpc -d | grep grpc | cut -d- -f2) && \
git clone --depth 1 -b v${GRPC_VERSION} https://github.com/grpc/grpc /tmp/grpc && \
cd /tmp/grpc/src/php/ext/grpc && \
phpize && \
./configure && \
make && \
make install && \
rm -rf /tmp/grpc && \
apk del --no-cache git grpc-dev $PHPIZE_DEPS && \
echo "extension=grpc.so" > /usr/local/etc/php/conf.d/grpc.ini
That fetches a precompiled version of the gRPC library and allows you to build only the PHP extension itself, which finishes in a matter of seconds.
Upvotes: 1
Reputation: 181
Installing GRPC in a pipeline takes a long time. I recommend using the cache of the provider used (bitbucket, github etc ..) or using a base image which is used as the starting point of the Dockerfile
FROM baseimage:latest
I have implemented an image based on alpine and php 7.4 with extension grpc installed, check it on github gits click here
Upvotes: 2
Reputation: 76699
In case gcc –version
says anything less than 4.9 ...this might be the cause.
This answer also seems to be related to your scenario... in case PECL fails.
Upvotes: 0