Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
Add compile step for protobuf ext
Browse files Browse the repository at this point in the history
  • Loading branch information
spaulg committed Sep 23, 2020
1 parent 7530c67 commit a63b25d
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ RUN ./configure \
--enable-soap=shared \
--with-zip=shared \
--with-kerberos=shared \
--enable-posix=shared
--enable-posix=shared \
--with-pear

RUN make -j$(nproc --all)
RUN make install
Expand All @@ -153,6 +154,39 @@ RUN cp php.ini-production /etc/php/php.ini
RUN mv /etc/php/php-fpm.conf.default /etc/php/php-fpm.conf
RUN rm -f /etc/php/php-fpm.d/*
RUN rm -f /usr/lib/php/extensions/*/*.a
RUN mkdir -p /etc/php/conf.d

RUN for ext in /usr/lib/php/extensions/*/*.so ; do filename=$(echo ${ext##*/}| cut -d'.' -f 1) ; \
echo "extension=$filename" >> "/etc/php/conf.d/00-$filename.ini" ; done && \
mv "/etc/php/conf.d/00-mysqlnd.ini" "/etc/php/conf.d/01-mysqlnd.ini" && \
mv "/etc/php/conf.d/00-pdo_mysql.ini" "/etc/php/conf.d/02-pdo_mysql.ini" && \
sed -i -e 's/extension/zend_extension/' /etc/php/conf.d/00-opcache.ini

# Copy grpc/protobuf dependencies
COPY --from=grpc_build /root/grpc/INSTALLROOT/ /

# Compile and install gRPC library
WORKDIR /root
RUN git clone -b v1.32.0 --depth 1 --single-branch --recursive https://github.com/grpc/grpc

# Compile and install the grpc php extension
WORKDIR /root/grpc/src/php/ext/grpc
RUN phpize
RUN ./configure
RUN make
RUN make install

WORKDIR /root
RUN git clone -b v3.13.0 --depth 1 --single-branch --recursive https://github.com/protocolbuffers/protobuf.git

# Compile and install the protobuf php extension
WORKDIR /root/protobuf/php/ext/google/protobuf

RUN phpize
RUN ./configure
RUN php make-preload.php
RUN make
RUN make install

# Copy grpc/protobuf dependencies
COPY --from=grpc_build /root/grpc/INSTALLROOT/ /
Expand Down Expand Up @@ -192,7 +226,6 @@ RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y \

RUN mkdir -p /etc/php/
RUN mkdir -p /usr/lib/php/extensions
RUN mkdir -p /etc/php/conf.d

COPY --from=php_build /usr/bin/php /usr/bin/
COPY --from=php_build /usr/sbin/php-fpm /usr/sbin/
Expand All @@ -203,12 +236,6 @@ COPY --from=php_build /usr/lib/php/extensions/ /usr/lib/php/extensions
COPY --from=grpc_build /root/grpc/INSTALLROOT/usr/lib/ /usr/lib/
COPY --from=grpc_build /root/grpc/INSTALLROOT/usr/share/grpc/roots.pem /usr/share/grpc/roots.pem

RUN for ext in /usr/lib/php/extensions/*/*.so ; do filename=$(echo ${ext##*/}| cut -d'.' -f 1) ; \
echo "extension=$filename" >> "/etc/php/conf.d/00-$filename.ini" ; done && \
mv "/etc/php/conf.d/00-mysqlnd.ini" "/etc/php/conf.d/01-mysqlnd.ini" && \
mv "/etc/php/conf.d/00-pdo_mysql.ini" "/etc/php/conf.d/02-pdo_mysql.ini" && \
sed -i -e 's/extension/zend_extension/' /etc/php/conf.d/00-opcache.ini

# Create phpfpm user/group
RUN groupadd -g 82 php
RUN useradd -u 82 -c "PHP Fast Process Manager" -g 82 -r -m -d /var/lib/php php
Expand Down

0 comments on commit a63b25d

Please sign in to comment.