Skip to content

Commit

Permalink
Add Dockerfile, update setting for kafka-confluent-python-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
ik8svip committed Dec 8, 2023
1 parent a4180ae commit 4fca4ba
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# @refernence:
# https://www.alibabacloud.com/help/zh/message-queue-for-apache-kafka/latest/sdk-for-python-send-and-consume-messages-by-using-an-ssl-endpoint-with-plain-authentication
# https://github.com/AliwareMQ/aliware-kafka-demos
#
FROM ubuntu:22.04

ENV ALI_KAFKA_BOOTSTRAP_SERVERS="kafka-1:9092,kafka-2:9092.kafka-3:9092'"
ENV ALI_KAFKA_TOPIC_NAME="YOUR_TOPIC_NAME"
ENV ALI_KAFKA_CONSUMER_ID="YOUR_GROUP_ID"
ENV ALI_KAFKA_DEMOS_REPO="https://github.com/AliwareMQ/aliware-kafka-demos"

RUN apt-get update \
&& apt-get -yq install \
git \
wget \
python3 \
python3-pip \
&& pip install confluent-kafka==1.9.2 \
&& wget https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20220826/ytsw/only-4096-ca-cert

ADD . /aliware-kafka-demos/
WORKDIR /aliware-kafka-demos/
CMD ["/bin/sleep", "infinity"]
12 changes: 9 additions & 3 deletions kafka-confluent-python-demo/vpc/setting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import os

bootstrap_servers = os.environ.get('ALI_KAFKA_BOOTSTRAP_SERVERS', 'kafka-1:9092,kafka-2:9092.kafka-3:9092').split(',')
topic_name = os.environ.get('ALI_KAFKA_TOPIC_NAME', 'YOUR_TOPIC_NAME')
consumer_id = os.environ.get('ALI_KAFKA_CONSUMER_ID', 'YOUR_GROUP_ID')

kafka_setting = {
'bootstrap_servers': 'xxx:xx,xxx:xx',
'topic_name': 'xxx',
'group_name': 'xxx'
'bootstrap_servers': bootstrap_servers,
'topic_name': topic_name,
'group_name': consumer_id,
}

0 comments on commit 4fca4ba

Please sign in to comment.