Skip to content

Commit

Permalink
Add docker-compose support. Fixes #1
Browse files Browse the repository at this point in the history
Fix exit by replacing .Fatal with .log
  • Loading branch information
sn123 committed May 28, 2020
1 parent b555e48 commit 9cea0e7
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ type EventData struct {
```
Kafka topics are great for pushing NRT metrices (Near Real Time) to the dashboard. Kafka topic bound widgets can be used to display Time series graphs or volatile values. Mustard already has built-in support for [ApexCharts](https://apexcharts.com/), which can be used for displaying charts.
### Docker compose
There's a docker compose file which exposes kafka listener both internally and externally. On windows, since traffic cannot be routed to linux containers, the kafka listener is exposed as host.docker.internal on the host. The docker-compose for windows is docker-compose-win.yml.
```shell
$ docker-compose -f ./docker-compose.yml up -d
```
Please make sure that mustard's env file has the topic you need to listen to (KAFKA_TOPIC)
The docker compose file uses https://github.com/wurstmeister/kafka-docker/, please refer to the documentation there to troubleshoot connectivity issues.
On windows, this is how it would potentially work:
1. Create the topic:
```.\kafka-topics.bat --bootstrap-server host.docker.internal:9094 --topic test --create```
2. Set the topic name in .env
3. Produce a message:
```.\kafka-console-producer.bat --bootstrap-server host.docker.internal:9094 --topic test```
### TODO
- Create wiki
- Drag and drop support
Expand Down
34 changes: 34 additions & 0 deletions docker-compose-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3.2'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka:latest
ports:
- target: 9094
published: 9094
protocol: tcp
mode: host
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
HOSTNAME_COMMAND: "docker info | grep ^Name: | cut -d' ' -f 2"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: INSIDE://:9092,OUTSIDE://host.docker.internal:9094
KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9094
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
volumes:
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- zookeeper
mustard:
build: .
ports:
- "8090:80"
environment:
KAFKA_URL: kafka:9092
env_file:
- .env
depends_on:
- kafka
34 changes: 34 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3.2'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka:latest
ports:
- target: 9094
published: 9094
protocol: tcp
mode: host
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
HOSTNAME_COMMAND: "docker info | grep ^Name: | cut -d' ' -f 2"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: INSIDE://:9092,OUTSIDE://_{HOSTNAME_COMMAND}:9094
KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9094
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
volumes:
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- zookeeper
mustard:
build: .
ports:
- "8090:80"
environment:
KAFKA_URL: kafka:9092
env_file:
- .env
depends_on:
- kafka
4 changes: 2 additions & 2 deletions jobs/number.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ func init() {
now := time.Now()
resp, err := http.Get(fmt.Sprintf(numberURL, now.Day()))
if err != nil {
log.Fatal(err)
log.Println(err)
return
}
defer resp.Body.Close()
text, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
log.Println(err)
return
}
data := mustardcore.EventData{Event: "clockWidget", Data: number{Trivia: string(text)}}
Expand Down

0 comments on commit 9cea0e7

Please sign in to comment.