Skip to content

Commit ad9bace

Browse files
committed
added publisher app and consumer app
Added a generate target that runs the namely/protoc-all Docker image to generate PHP gRPC code from protos/messages.proto for both the publisher-app and consumer-app projects. The generated PHP files are output to the app/Grpc directory in each app. Setting up roadrunner service in supervisor Publisher in publisher-app and Receiver on consumer-app
1 parent b37f33b commit ad9bace

File tree

137 files changed

+23425
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+23425
-0
lines changed

consumer-app/.docker/Dockerfile

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
FROM ubuntu:24.04
2+
3+
LABEL maintainer="Taylor Otwell"
4+
5+
ARG WWWGROUP
6+
ARG NODE_VERSION=22
7+
ARG MYSQL_CLIENT="mysql-client"
8+
ARG POSTGRES_VERSION=17
9+
10+
WORKDIR /var/www/html
11+
12+
ENV DEBIAN_FRONTEND=noninteractive
13+
ENV TZ=UTC
14+
ENV SUPERVISOR_PHP_COMMAND="/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80"
15+
ENV SUPERVISOR_PHP_USER="sail"
16+
ENV PATH="$PATH:/root/.composer/vendor/bin"
17+
18+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
19+
20+
RUN echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99custom && \
21+
echo "Acquire::http::No-Cache true;" >> /etc/apt/apt.conf.d/99custom && \
22+
echo "Acquire::BrokenProxy true;" >> /etc/apt/apt.conf.d/99custom
23+
24+
RUN apt-get update && apt-get upgrade -y
25+
RUN mkdir -p /etc/apt/keyrings
26+
RUN apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python3 dnsutils librsvg2-bin fswatch ffmpeg nano
27+
RUN curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xb8dc7e53946656efbce4c1dd71daeaab4ad4cab6' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null
28+
RUN echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble main" > /etc/apt/sources.list.d/ppa_ondrej_php.list
29+
RUN apt-get update
30+
RUN apt-get install -y php8.4-cli php8.4-dev \
31+
php8.4-pgsql php8.4-sqlite3 php8.4-gd \
32+
php8.4-curl php8.4-mongodb \
33+
php8.4-imap php8.4-mysql php8.4-mbstring \
34+
php8.4-xml php8.4-zip php8.4-bcmath php8.4-soap \
35+
php8.4-intl php8.4-readline \
36+
php8.4-ldap \
37+
php8.4-msgpack php8.4-igbinary php8.4-redis php8.4-swoole \
38+
php8.4-memcached php8.4-pcov php8.4-imagick php8.4-xdebug
39+
RUN curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
40+
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
41+
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x nodistro main" > /etc/apt/sources.list.d/nodesource.list
42+
RUN apt-get update
43+
RUN apt-get install -y nodejs
44+
RUN npm install -g npm
45+
RUN npm install -g pnpm
46+
RUN npm install -g bun
47+
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /etc/apt/keyrings/yarn.gpg >/dev/null
48+
RUN echo "deb [signed-by=/etc/apt/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list
49+
RUN curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/keyrings/pgdg.gpg >/dev/null
50+
RUN echo "deb [signed-by=/etc/apt/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt noble-pgdg main" > /etc/apt/sources.list.d/pgdg.list
51+
RUN apt-get update
52+
RUN apt-get install -y yarn
53+
RUN apt-get install -y $MYSQL_CLIENT
54+
RUN apt-get install -y postgresql-client-$POSTGRES_VERSION
55+
# RUN pecl install grpc protobuf
56+
# # RUN docker-php-ext-enable grpc protobuf
57+
# RUN echo "extension=grpc.so" > /etc/php/8.4/cli/conf.d/99-grpc.ini && \
58+
# echo "extension=protobuf.so" > /etc/php/8.4/cli/conf.d/99-protobuf.ini
59+
60+
# gRPC tooling libs
61+
# RUN apt-get install -y libgrpc-dev libpng-dev zlib1g-dev libicu-dev libonig-dev libxml2-dev libprotobuf-dev protobuf-compiler
62+
63+
# COPY ./.docker/php-extensions/*.so /usr/lib/php/20240924/
64+
RUN mkdir -p /tmp/php-extensions
65+
RUN curl -L https://github.com/rxcod9/laravel-grpc-example/releases/download/v1.0.0/php8.4-grpc.so.tar.gz \
66+
| tar -xz -C /tmp/php-extensions
67+
RUN curl -L https://github.com/rxcod9/laravel-grpc-example/releases/download/v1.0.0/php8.4-protobuf.so.tar.gz \
68+
| tar -xz -C /tmp/php-extensions
69+
RUN cp -r /tmp/php-extensions/*.so /usr/lib/php/20240924/
70+
RUN rm -rf /tmp/php-extensions
71+
RUN echo "extension=grpc.so" > /etc/php/8.4/cli/conf.d/99-grpc.ini && \
72+
echo "extension=protobuf.so" > /etc/php/8.4/cli/conf.d/99-protobuf.ini
73+
74+
# Create directory for binaries
75+
RUN mkdir -p /usr/local/bin
76+
77+
# Download and extract RR binary safely in /tmp, then move to /usr/local/bin
78+
RUN mkdir -p /tmp/roadrunner
79+
RUN curl -L https://github.com/roadrunner-server/roadrunner/releases/download/v2025.1.2/roadrunner-2025.1.2-linux-amd64.tar.gz \
80+
| tar -xz -C /tmp/roadrunner --strip-components=1
81+
RUN mv /tmp/roadrunner/rr /usr/local/bin/rr
82+
RUN chmod +x /usr/local/bin/rr
83+
RUN rm -rf /tmp/roadrunner
84+
85+
# Copy gRPC binaries and extension from grpc-base
86+
# COPY --from=grpc-base /github/grpc/cmake/build/third_party/protobuf/protoc /usr/local/bin/protoc
87+
# COPY --from=grpc-base /github/grpc/cmake/build/grpc_php_plugin /usr/local/bin/protoc-gen-grpc
88+
# COPY --from=grpc-base /usr/local/lib/php/extensions/no-debug-non-zts-20190902/grpc.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/grpc.so
89+
90+
# # Enable grpc
91+
# RUN echo "extension=grpc.so" > /etc/php/8.4/cli/conf.d/20-grpc.ini
92+
93+
94+
RUN apt-get -y autoremove
95+
RUN apt-get clean
96+
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
97+
98+
RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.4
99+
100+
RUN userdel -r ubuntu
101+
RUN groupadd --force -g $WWWGROUP sail
102+
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
103+
104+
COPY ./.docker/start-container /usr/local/bin/start-container
105+
COPY ./.docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
106+
COPY ./.docker/php.ini /etc/php/8.4/cli/conf.d/99-sail.ini
107+
RUN chmod +x /usr/local/bin/start-container
108+
109+
EXPOSE 80/tcp 50051/tcp
110+
111+
ENTRYPOINT ["start-container"]

consumer-app/.docker/php.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[PHP]
2+
post_max_size = 100M
3+
upload_max_filesize = 100M
4+
variables_order = EGPCS
5+
pcov.directory = .
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
if [ "$SUPERVISOR_PHP_USER" != "root" ] && [ "$SUPERVISOR_PHP_USER" != "sail" ]; then
4+
echo "You should set SUPERVISOR_PHP_USER to either 'sail' or 'root'."
5+
exit 1
6+
fi
7+
8+
if [ ! -z "$WWWUSER" ]; then
9+
usermod -u $WWWUSER sail
10+
fi
11+
12+
if [ ! -d /.composer ]; then
13+
mkdir /.composer
14+
fi
15+
16+
# if [ ! -f ./rr ]; then
17+
# ./vendor/bin/rr get-binary
18+
# chmod +x ./rr
19+
# fi
20+
21+
chmod -R ugo+rw /.composer
22+
23+
if [ $# -gt 0 ]; then
24+
if [ "$SUPERVISOR_PHP_USER" = "root" ]; then
25+
exec "$@"
26+
else
27+
exec gosu $WWWUSER "$@"
28+
fi
29+
else
30+
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
31+
fi
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[supervisord]
2+
nodaemon=true
3+
user=root
4+
logfile=/var/log/supervisor/supervisord.log
5+
pidfile=/var/run/supervisord.pid
6+
; logfile=/dev/null
7+
logfile_maxbytes=0
8+
9+
[program:php]
10+
command=%(ENV_SUPERVISOR_PHP_COMMAND)s
11+
user=%(ENV_SUPERVISOR_PHP_USER)s
12+
environment=LARAVEL_SAIL="1"
13+
stdout_logfile=/dev/stdout
14+
stdout_logfile_maxbytes=0
15+
stderr_logfile=/dev/stderr
16+
stderr_logfile_maxbytes=0
17+
18+
[program:roadrunner]
19+
directory=/var/www/html
20+
command=rr serve -c /var/www/html/.rr.yaml
21+
autostart=true
22+
autorestart=true
23+
user=sail
24+
stdout_logfile=/dev/stdout
25+
stdout_logfile_maxbytes=0
26+
stderr_logfile=/dev/stderr
27+
stderr_logfile_maxbytes=0

consumer-app/.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

consumer-app/.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto eol=lf
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
10+
CHANGELOG.md export-ignore
11+
.styleci.yml export-ignore

consumer-app/.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
*.log
2+
.DS_Store
3+
.env
4+
.env.backup
5+
.env.production
6+
.phpactor.json
7+
.phpunit.result.cache
8+
/.fleet
9+
/.idea
10+
/.nova
11+
/.phpunit.cache
12+
/.vscode
13+
/.zed
14+
/auth.json
15+
/node_modules
16+
/public/build
17+
/public/hot
18+
/public/storage
19+
/storage/*.key
20+
/storage/pail
21+
/vendor
22+
Homestead.json
23+
Homestead.yaml
24+
Thumbs.db
25+
./rr

consumer-app/.rr.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: "3"
2+
3+
rpc:
4+
listen: "tcp://127.0.0.1:6001"
5+
6+
server:
7+
command: "php bootstrap.php"
8+
relay: "pipes"
9+
10+
grpc:
11+
listen: "0.0.0.0:50051"
12+
proto:
13+
- "protos/messages.proto"

consumer-app/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
2+
3+
<p align="center">
4+
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
5+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
6+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
7+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
8+
</p>
9+
10+
## About Laravel
11+
12+
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
13+
14+
- [Simple, fast routing engine](https://laravel.com/docs/routing).
15+
- [Powerful dependency injection container](https://laravel.com/docs/container).
16+
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
17+
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
18+
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
19+
- [Robust background job processing](https://laravel.com/docs/queues).
20+
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
21+
22+
Laravel is accessible, powerful, and provides tools required for large, robust applications.
23+
24+
## Learning Laravel
25+
26+
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
27+
28+
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
29+
30+
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
31+
32+
## Laravel Sponsors
33+
34+
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
35+
36+
### Premium Partners
37+
38+
- **[Vehikl](https://vehikl.com)**
39+
- **[Tighten Co.](https://tighten.co)**
40+
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
41+
- **[64 Robots](https://64robots.com)**
42+
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
43+
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
44+
- **[Redberry](https://redberry.international/laravel-development)**
45+
- **[Active Logic](https://activelogic.com)**
46+
47+
## Contributing
48+
49+
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
50+
51+
## Code of Conduct
52+
53+
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
54+
55+
## Security Vulnerabilities
56+
57+
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
58+
59+
## License
60+
61+
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

consumer-app/app/Grpc/GPBMetadata/Protos/Messages.php

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)