fixing docker-compose startup

This commit is contained in:
Thilo Behnke
2022-08-10 18:39:10 +02:00
parent 5265dff239
commit bcc8c8d2d1
4 changed files with 58 additions and 18 deletions

53
docker-compose.dev.yml Normal file
View File

@@ -0,0 +1,53 @@
version: "3"
services:
zookeeper:
container_name: pong_server_zookeeper
image: 'bitnami/zookeeper:latest'
ports:
- '2181:2181'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
kafka:
container_name: pong_server_kafka
build:
context: ./kafka
ports:
- '9092:9092'
- '9093:9093'
- '7243:7243'
environment:
- KAFKA_BROKER_ID=1
- KAFKA_CFG_INTER_BROKER_LISTENER_NAME=DOCKER
- KAFKA_CFG_LISTENERS=LOCAL://:9093,DOCKER://kafka:9092
- KAFKA_CFG_ADVERTISED_LISTENERS=LOCAL://127.0.0.1:9093,DOCKER://kafka:9092
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=LOCAL:PLAINTEXT,DOCKER:PLAINTEXT
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper
healthcheck:
test: [ "CMD", "/opt/bitnami/kafka/bin/kafka-topics.sh", "--bootstrap-server", "localhost:9093", "--describe"]
interval: 30s
timeout: 10s
retries: 5
server:
container_name: pong_server
build:
context: ./server
ports:
- '4000:4000'
restart: on-failure
depends_on:
- kafka
environment:
KAFKA_HOST: 'kafka:9092'
KAFKA_TOPIC_MANAGER_HOST: 'kafka:7243'
nginx:
container_name: pong_nginx
build:
context: ./client
environment:
- API_SERVER=localhost
ports:
- '80:80'
network_mode: 'host'

View File

@@ -50,15 +50,5 @@ services:
- API_SERVER=pong_server
ports:
- '80:80'
network_mode: 'host'
# command: [ nginx-debug, '-g', 'daemon off;' ]
# kaka-rest-proxy:
# container_name: pong_server_kafka_rest_proxy
# image: 'confluentinc/cp-kafka-rest'
# ports:
# - '8082:8082'
# environment:
# - KAFKA_REST_BOOTSTRAP_SERVERS=kafka:9092
# depends_on:
# - kafka
depends_on:
- server

View File

@@ -112,7 +112,7 @@ metadata:
labels:
wasm.pong.io/name: kafka
spec:
replicas: 1
replicas: 3
selector:
matchLabels:
wasm.pong.io/name: kafka
@@ -130,9 +130,6 @@ spec:
- containerPort: 7243
name: topic-svc
env:
- name: KAFKA_BROKER_ID
# TODO: How to manage the broker id with multiple replicas?
value: "1"
- name: KAFKA_CFG_INTER_BROKER_LISTENER_NAME
# TODO: This will not work with multiple replicas
value: LOCAL

View File

@@ -13,8 +13,8 @@ cp -r ./pong ./client/wasm/
cp -r ./pong ./server/
echo "Start docker containers."
docker-compose down
docker-compose up -d --build --force-recreate kafka zookeeper nginx
docker-compose -f docker-compose.dev.yml down
docker-compose -f docker-compose.dev.yml up -d --build --force-recreate kafka zookeeper nginx
echo "Remove temporary local dependencies from components."
rm -rf ./client/wasm/pong