Skip to content

Commit

Permalink
PHP: update examples (grpc#28159)
Browse files Browse the repository at this point in the history
* PHP: update examples

* Fix templates
  • Loading branch information
stanley-cheung authored Dec 1, 2021
1 parent 789e8b3 commit f3ef686
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 33 deletions.
2 changes: 1 addition & 1 deletion examples/php/echo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For all the following examples, we use a simple gRPC server, written in Node.
```sh
$ git clone https://github.com/grpc/grpc-web
$ cd grpc-web
$ docker-compose build common node-server
$ docker-compose build prereqs node-server
$ docker run -d -p 9090:9090 --name node-server grpcweb/node-server
```

Expand Down
5 changes: 3 additions & 2 deletions examples/php/echo/apache.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ RUN apt-get -qq update && apt-get -qq install -y git

COPY --from=composer /usr/bin/composer /usr/bin/composer

COPY --from=grpc-base /usr/local/bin/protoc /usr/local/bin/protoc
COPY --from=grpc-base /github/grpc/cmake/build/third_party/protobuf/protoc \
/usr/local/bin/protoc

COPY --from=grpc-base /github/grpc/bins/opt/grpc_php_plugin \
COPY --from=grpc-base /github/grpc/cmake/build/grpc_php_plugin \
/usr/local/bin/protoc-gen-grpc

COPY --from=grpc-base \
Expand Down
18 changes: 6 additions & 12 deletions examples/php/echo/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,20 @@
FROM php:7.2-stretch

RUN apt-get -qq update && apt-get -qq install -y \
autoconf automake curl git libtool \
autoconf automake cmake curl git libtool \
pkg-config unzip zlib1g-dev

ARG MAKEFLAGS=-j8


WORKDIR /tmp

RUN curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v3.8.0/\
protoc-3.8.0-linux-x86_64.zip -o /tmp/protoc.zip && \
unzip -qq protoc.zip && \
cp /tmp/bin/protoc /usr/local/bin/protoc


WORKDIR /github/grpc

RUN git clone https://github.com/grpc/grpc . && \
git submodule update --init && \
cd third_party/protobuf && git submodule update --init
git submodule update --init --recursive

WORKDIR /github/grpc/cmake/build

RUN make grpc_php_plugin
RUN cmake ../.. && \
make protoc grpc_php_plugin

RUN pecl install grpc
5 changes: 3 additions & 2 deletions examples/php/echo/cli.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ RUN apt-get -qq update && apt-get -qq install -y git

COPY --from=composer /usr/bin/composer /usr/bin/composer

COPY --from=grpc-base /usr/local/bin/protoc /usr/local/bin/protoc
COPY --from=grpc-base /github/grpc/cmake/build/third_party/protobuf/protoc \
/usr/local/bin/protoc

COPY --from=grpc-base /github/grpc/bins/opt/grpc_php_plugin \
COPY --from=grpc-base /github/grpc/cmake/build/grpc_php_plugin \
/usr/local/bin/protoc-gen-grpc

COPY --from=grpc-base \
Expand Down
5 changes: 3 additions & 2 deletions examples/php/echo/fpm.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ RUN apt-get -qq update && apt-get -qq install -y git

COPY --from=composer /usr/bin/composer /usr/bin/composer

COPY --from=grpc-base /usr/local/bin/protoc /usr/local/bin/protoc
COPY --from=grpc-base /github/grpc/cmake/build/third_party/protobuf/protoc \
/usr/local/bin/protoc

COPY --from=grpc-base /github/grpc/bins/opt/grpc_php_plugin \
COPY --from=grpc-base /github/grpc/cmake/build/grpc_php_plugin \
/usr/local/bin/protoc-gen-grpc

COPY --from=grpc-base \
Expand Down
18 changes: 6 additions & 12 deletions templates/examples/php/echo/base.Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,20 @@
FROM php:${settings.php_version.php_current_version()}-${settings.php_version.php_debian_version()}

RUN apt-get -qq update && apt-get -qq install -y ${'\\'}
autoconf automake curl git libtool ${'\\'}
autoconf automake cmake curl git libtool ${'\\'}
pkg-config unzip zlib1g-dev

ARG MAKEFLAGS=-j8


WORKDIR /tmp

RUN curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v3.8.0/${'\\'}
protoc-3.8.0-linux-x86_64.zip -o /tmp/protoc.zip && ${'\\'}
unzip -qq protoc.zip && ${'\\'}
cp /tmp/bin/protoc /usr/local/bin/protoc


WORKDIR /github/grpc

RUN git clone https://github.com/grpc/grpc . && ${'\\'}
git submodule update --init && ${'\\'}
cd third_party/protobuf && git submodule update --init
git submodule update --init --recursive

WORKDIR /github/grpc/cmake/build

RUN make grpc_php_plugin
RUN cmake ../.. && ${'\\'}
make protoc grpc_php_plugin

RUN pecl install grpc
5 changes: 3 additions & 2 deletions templates/examples/php/echo/copy_from_grpc_base.include
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
COPY --from=composer /usr/bin/composer /usr/bin/composer

COPY --from=grpc-base /usr/local/bin/protoc /usr/local/bin/protoc
COPY --from=grpc-base /github/grpc/cmake/build/third_party/protobuf/protoc ${'\\'}
/usr/local/bin/protoc

COPY --from=grpc-base /github/grpc/bins/opt/grpc_php_plugin ${'\\'}
COPY --from=grpc-base /github/grpc/cmake/build/grpc_php_plugin ${'\\'}
/usr/local/bin/protoc-gen-grpc

COPY --from=grpc-base ${'\\'}
Expand Down

0 comments on commit f3ef686

Please sign in to comment.