Skip to content

Commit 0cc0109

Browse files
authored
Restructure (#3)
* update docker files * save work on restructure * save work on restructure * save work on restructure * adjust templates
1 parent 3f742e4 commit 0cc0109

32 files changed

+681
-53
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
/vendor/
1+
**/vendor/
22
/.idea
33
/keys
4-
composer.lock
4+
**/composer.lock
5+
**/*.iml
56
src/jc
67
docker-compose.jc.yml

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,22 @@
22
This repository has PHP examples for Kafka consumers / producers for:
33
- [php-rdkafka](https://github.com/arnaud-lb/php-rdkafka): Examples just using the PHP extension
44
- [php-kafka-lib](https://github.com/jobcloud/php-kafka-lib): PHP library that relies on [php-rdkafka](https://github.com/arnaud-lb/php-rdkafka) and supports [avro](https://github.com/flix-tech/avro-serde-php)
5+
- [php-simple-kafka-client](https://github.com/php-kafka/php-simple-kafka-client): Examples just using the PHP extension
6+
- [php-simple-kafka-lib](https://github.com/php-kafka/php-simple-kafka-lib): PHP library that relies on [php-simple-kafka-client](https://github.com/php-kafka/php-simple-kafka-client) and supports [avro](https://github.com/flix-tech/avro-serde-php)
57

68
## Examples
7-
- [php-rdkafka](src/ext-php-rdkafka/pure-php)
8-
- [php-kafka-lib](src/ext-php-rdkafka/php-kafka-lib)
9-
10-
## Start containers for examples
11-
Be sure to start the docker containers.
12-
To do so, run this in the project root:
13-
```bash
14-
docker-compose up -d
15-
docker-compose exec php bash
16-
```
17-
Then follow the instructions in the example folders.
9+
Checkout these folders to see how to run the examples:
10+
- [php-rdkafka](src/ext-php-rdkafka)
11+
- [php-simple-kafka-client](src/ext-php-simple-kafka-client)
1812

1913
## Customize to fit your setup
2014
If you wan't to test / debug something that is closer to your setup,
2115
you can modify the following arguments in `docker-compose.yml`:
2216
```
23-
PHP_IMAGE_TAG: 7.4-cli-alpine3.11
24-
LIBRDKAFKA_VERSION: v1.4.0
25-
PHP_RDKAFKA_VERSION: 4.0.3
17+
PHP_IMAGE_TAG: 8.0-cli-alpine3.13
18+
LIBRDKAFKA_VERSION: v1.6.1
19+
PHP_EXTENSION: php-kafka/php-simple-kafka-client
20+
PHP_EXTENSION_VERSION: v0.1.1
2621
```
2722
Adjust those, to reflect your setup and afterwards run:
2823
```
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: '3.7'
2+
services:
3+
php:
4+
build:
5+
context: ../php
6+
dockerfile: Dockerfile.alpine
7+
args:
8+
PHP_IMAGE_TAG: 8.0-cli-alpine3.13
9+
LIBRDKAFKA_VERSION: v1.6.1
10+
PHP_EXTENSION: arnaud-lb/php-rdkafka
11+
PHP_EXTENSION_VERSION: 5.0.0
12+
tty: true
13+
working_dir: /app
14+
volumes:
15+
- ./:/app
16+
redpanda:
17+
entrypoint:
18+
- /usr/bin/rpk
19+
- redpanda
20+
- start
21+
- --smp
22+
- '1'
23+
- --reserve-memory
24+
- 0M
25+
- --overprovisioned
26+
- --node-id
27+
- '0'
28+
- --check=false
29+
image: vectorized/redpanda:v21.4.7
30+
ports:
31+
- 9092:9092
32+
- 29092:29092
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
version: '3.7'
2+
services:
3+
php:
4+
build:
5+
context: ../php
6+
dockerfile: Dockerfile.alpine
7+
args:
8+
PHP_IMAGE_TAG: 8.0-cli-alpine3.13
9+
LIBRDKAFKA_VERSION: v1.6.1
10+
PHP_EXTENSION: php-kafka/php-simple-kafka-client
11+
PHP_EXTENSION_VERSION: v0.1.1
12+
tty: true
13+
working_dir: /app
14+
volumes:
15+
- ./:/app
16+
17+
zookeeper:
18+
image: confluentinc/cp-zookeeper:6.1.1
19+
environment:
20+
ZOOKEEPER_CLIENT_PORT: 2182
21+
ZOOKEEPER_TICK_TIME: 2000
22+
23+
kafka:
24+
image: confluentinc/cp-kafka:6.1.1
25+
depends_on:
26+
- zookeeper
27+
ports:
28+
- 9096:9096
29+
environment:
30+
KAFKA_BROKER_ID: 1
31+
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2182'
32+
KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://kafka:9096'
33+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
34+
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
35+
KAFKA_NUM_PARTITIONS: 1
36+
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
37+
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
38+
39+
kafka-schema-registry:
40+
image: confluentinc/cp-schema-registry:6.1.1
41+
depends_on:
42+
- zookeeper
43+
- kafka
44+
ports:
45+
- "9083:9083"
46+
environment:
47+
SCHEMA_REGISTRY_HOST_NAME: kafka-schema-registry
48+
SCHEMA_REGISTRY_LISTENERS: "http://0.0.0.0:9083"
49+
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2182'
50+
SCHEMA_REGISTRY_AVRO_COMPATIBILITY_LEVEL: 'full_transitive'

docker-compose.centos.yml renamed to docker/docker-compose-templates/docker-compose.centos.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ version: '3.7'
22
services:
33
php:
44
build:
5-
context: ./docker/php
6-
dockerfile: Dockerfile.centos
5+
context: ../php
6+
dockerfile: ../php/Dockerfile.centos
77
args:
88
CENTOS_VERSION: 7
99
PHP_VERSION: 74

docker-compose.debug.yml renamed to docker/docker-compose-templates/docker-compose.debug.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ version: '3.7'
22
services:
33
php:
44
build:
5-
context: ./docker/php
6-
dockerfile: Dockerfile.debug
5+
context: ../php
6+
dockerfile: ../php/Dockerfile.debug
77
args:
88
PHP_VERSION: 7.4.14
99
LIBRDKAFKA_VERSION: v1.5.3
10-
PHP_RDKAFKA_VERSION: 5.x
10+
PHP_RDKAFKA_VERSION: 5.0.0
1111
tty: true
1212
working_dir: /app
1313
volumes:

docker-compose.master.yml renamed to docker/docker-compose-templates/docker-compose.master.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ version: '3.7'
22
services:
33
php:
44
build:
5-
context: ./docker/php
6-
dockerfile: Dockerfile.master
5+
context: ../php
6+
dockerfile: ../php/Dockerfile.master
77
args:
88
LIBRDKAFKA_VERSION: v1.5.0
99
tty: true

docker/php/Dockerfile.alpine

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ ARG PHP_IMAGE_TAG
33
FROM php:${PHP_IMAGE_TAG}
44

55
ARG LIBRDKAFKA_VERSION
6-
ARG PHP_RDKAFKA_VERSION
6+
ARG PHP_EXTENSION
7+
ARG PHP_EXTENSION_VERSION
8+
9+
710

811
# Install packages
912
RUN apk --no-cache upgrade && \
@@ -16,8 +19,8 @@ RUN git clone --depth 1 --branch ${LIBRDKAFKA_VERSION} https://github.com/edenhi
1619
&& ./configure \
1720
&& make \
1821
&& make install \
19-
&& git clone --depth 1 --branch ${PHP_RDKAFKA_VERSION} https://github.com/arnaud-lb/php-rdkafka.git \
20-
&& cd php-rdkafka \
22+
&& git clone --depth 1 --branch ${PHP_EXTENSION_VERSION} https://github.com/${PHP_EXTENSION}.git \
23+
&& cd $(basename ${PHP_EXTENSION}) \
2124
&& phpize \
2225
&& ./configure \
2326
&& make all -j 5 \
@@ -26,7 +29,11 @@ RUN git clone --depth 1 --branch ${LIBRDKAFKA_VERSION} https://github.com/edenhi
2629

2730
# Install php extensions
2831
RUN docker-php-ext-install pcntl && \
29-
docker-php-ext-enable rdkafka pcntl > /dev/null 2>&1
32+
if [ ${PHP_EXTENSION} = "arnaud-lb/php-rdkafka" ]; then \
33+
docker-php-ext-enable rdkafka pcntl > /dev/null 2>&1; \
34+
else \
35+
docker-php-ext-enable simple_kafka_client pcntl > /dev/null 2>&1; \
36+
fi
3037

3138
# Install composer
3239
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

src/ext-php-rdkafka/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Running the examples
2+
1. `docker-compose up -d`
3+
2. `docker-compose exec php composer update`
4+
3. Check the subfolders on how to run the examples
File renamed without changes.

0 commit comments

Comments
 (0)