Browse Source

[php] Fix #9021 fail to build grpc (#9032)

* Fix #9021 fail to build grpc

* Add OPCache, JIT, clean dockerfile

* Move Pecl build up
for faster local builds when only change the code
Joan Miquel 1 year ago
parent
commit
b283599b18

+ 0 - 17
frameworks/PHP/spiral/php/install-composer.sh

@@ -1,17 +0,0 @@
-#!/bin/sh
-
-EXPECTED_SIGNATURE="$(curl -s https://composer.github.io/installer.sig)"
-php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
-ACTUAL_SIGNATURE="$(php -r "echo hash_file('SHA384', 'composer-setup.php');")"
-
-if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
-then
-    >&2 echo 'ERROR: Invalid installer signature'
-    rm composer-setup.php
-    exit 1
-fi
-
-php composer-setup.php --quiet
-RESULT=$?
-rm composer-setup.php
-exit $RESULT

+ 5 - 0
frameworks/PHP/spiral/php/php.ini

@@ -1909,6 +1909,11 @@ opcache.huge_code_pages=1
 ; SSL stream context option.
 ; SSL stream context option.
 ;openssl.capath=
 ;openssl.capath=
 
 
+
+
+opcache.jit_buffer_size=128M
+opcache.jit=tracing
+
 ; Local Variables:
 ; Local Variables:
 ; tab-width: 4
 ; tab-width: 4
 ; End:
 ; End:

+ 14 - 16
frameworks/PHP/spiral/spiral.dockerfile

@@ -1,26 +1,24 @@
 FROM php:8.3-cli
 FROM php:8.3-cli
 
 
-RUN docker-php-ext-install pdo_mysql > /dev/null
+RUN apt-get update -yqq > /dev/null && apt-get install -yqq git unzip > /dev/null
+COPY --from=composer/composer:latest-bin --link /composer /usr/local/bin/composer
 
 
-# Workaround solution for installing ext-sockets for PHP 8.0
-# See https://github.com/docker-library/php/issues/1245
-RUN CFLAGS="$CFLAGS -D_GNU_SOURCE" docker-php-ext-install sockets > /dev/null
+RUN docker-php-ext-install \
+    opcache \
+    pdo_mysql \
+    sockets > /dev/null
+
+# RoadRunner >= 2024.x.x requires protobuf extensions to be installed
+ARG PROTOBUF_VERSION="4.26.1"
+RUN pecl channel-update pecl.php.net
+RUN MAKEFLAGS="-j $(nproc)" pecl install protobuf-${PROTOBUF_VERSION} > /dev/null
 
 
-ADD ./ /spiral
 WORKDIR /spiral
 WORKDIR /spiral
+COPY --link . .
 
 
 # composer and opcache settings
 # composer and opcache settings
-COPY php/* /usr/local/etc/php/
-RUN chmod +x /usr/local/etc/php/install-composer.sh && /usr/local/etc/php/install-composer.sh
-
-# install dependencies
-RUN apt-get update -yqq > /dev/null && apt-get install -yqq git unzip > /dev/null
-RUN php composer.phar install --optimize-autoloader --classmap-authoritative --no-dev
-
-# RoadRunner >= 2024.x.x requires protobuf and grpc extensions to be installed
-ARG PROTOBUF_VERSION="4.26.1"
-RUN pecl channel-update pecl.php.net
-RUN MAKEFLAGS="-j $(nproc)" pecl install protobuf-${PROTOBUF_VERSION} grpc
+COPY --link php/php.ini /usr/local/etc/php/
+RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet
 
 
 # pre-configure
 # pre-configure
 RUN ./vendor/bin/rr get-binary > /dev/null 2>&1
 RUN ./vendor/bin/rr get-binary > /dev/null 2>&1