Skip to content

Commit

Permalink
Replaced sed with envsubst
Browse files Browse the repository at this point in the history
  • Loading branch information
cer committed Feb 23, 2022
1 parent 543f314 commit 389ee45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion kafka/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM amazoncorretto:8u322-al2
ENV KAFKA_VERSION=kafka_2.13-2.8.1
RUN yum install -y wget tar gzip nc && \
RUN yum install -y wget tar gzip nc gettext && \
echo https://dlcdn.apache.org/kafka/3.0.0/${KAFKA_VERSION}.tgz && \
(wget -q -O - https://dlcdn.apache.org/kafka/2.8.1/${KAFKA_VERSION}.tgz | tar -xzf - -C /usr/local) && \
yum clean all && \
Expand Down
12 changes: 6 additions & 6 deletions kafka/config/server.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ broker.id=0

# still cached

listeners=KAFKA_LISTENERS
advertised.listeners=KAFKA_ADVERTISED_LISTENERS
listener.security.protocol.map=KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
inter.broker.listener.name=KAFKA_INTER_BROKER_LISTENER_NAME
offsets.topic.replication.factor=KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
listeners=${KAFKA_LISTENERS}
advertised.listeners=${KAFKA_ADVERTISED_LISTENERS}
listener.security.protocol.map=${KAFKA_LISTENER_SECURITY_PROTOCOL_MAP}
inter.broker.listener.name=${KAFKA_INTER_BROKER_LISTENER_NAME}
offsets.topic.replication.factor=${KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR}


# The number of threads handling network requests
Expand Down Expand Up @@ -117,7 +117,7 @@ log.retention.check.interval.ms=300000
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=KAFKA_ZOOKEEPER_CONNECT
zookeeper.connect=${KAFKA_ZOOKEEPER_CONNECT}


# Timeout in ms for connecting to zookeeper
Expand Down
12 changes: 1 addition & 11 deletions kafka/run-kafka.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ set -e

EFFECTIVE_KAFKA_CONFIG_DIR=./config

cp -v /usr/local/kafka-config/* $EFFECTIVE_KAFKA_CONFIG_DIR

sed -i \
-e "s?KAFKA_LISTENERS?${KAFKA_LISTENERS?}?" \
-e "s?KAFKA_ADVERTISED_LISTENERS?${KAFKA_ADVERTISED_LISTENERS?}?" \
-e "s?KAFKA_INTER_BROKER_LISTENER_NAME?${KAFKA_INTER_BROKER_LISTENER_NAME?}?" \
-e "s?KAFKA_ZOOKEEPER_CONNECT?${KAFKA_ZOOKEEPER_CONNECT?}?" \
-e "s?KAFKA_LISTENER_SECURITY_PROTOCOL_MAP?${KAFKA_LISTENER_SECURITY_PROTOCOL_MAP?}?" \
-e "s?KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR?${KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR?}?" \
$EFFECTIVE_KAFKA_CONFIG_DIR/server.properties

envsubst < /usr/local/kafka-config/server.properties > $EFFECTIVE_KAFKA_CONFIG_DIR/server.properties

exec bin/kafka-server-start.sh $EFFECTIVE_KAFKA_CONFIG_DIR/server.properties

0 comments on commit 389ee45

Please sign in to comment.