Skip to content

Commit

Permalink
Fix docker image based on micronaut
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Feb 23, 2019
1 parent 9d2e506 commit 4bf2339
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM openjdk:8-jre-alpine
WORKDIR /app
COPY docker /
ENTRYPOINT ["docker-entrypoint.sh"]
ENV MICRONAUT_CONFIG_FILES=/app/application.yml
CMD ["./kafkahq"]
59 changes: 28 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,58 +64,55 @@ First you need a [configuration files](#configuration) in order to configure Kaf
```sh
docker run -d \
-p 8080:8080 \
-v /tmp/application.conf:/app/application.conf \
-v /tmp/application.yml:/app/application.yml \
tchiotludo/kafkahq
```
* With `-v /tmp/application.conf` must be an absolute path to configuration file
* With `-v /tmp/application.yml` must be an absolute path to configuration file
* Go to https://localhost:8080


### Stand Alone

* Install Java 8
* Download the latest jar on [release page](https://github.com/tchiotludo/kafkahq/releases)
* Create an `application.conf` in the same directory
* Launch the application with `java -jar kafkahq.jar prod`
* Create an [configuration files](#configuration)
* Launch the application with `java -Dmicronaut.config.files=/path/to/application.yml -jar kafkahq.jar`
* Go to https://localhost:8080


## Configuration
Configuration file is a [HOCON configuration](https://github.com/lightbend/config/blob/master/HOCON.md) file with an example below :
```
{
kafka {
connections {
my-cluster-1 {
properties {
bootstrap.servers: "kafka:9092"
}
registry: "https://schema-registry:8085"
}
my-cluster-2 {
properties {
bootstrap.servers: "kafka:9093"
security.protocol: SSL
ssl.truststore.location: /app/truststore.jks
ssl.truststore.password: password
ssl.keystore.location: /app/keystore.jks
ssl.keystore.password: password
ssl.key.password: password
}
}
}
}
}
Configuration file can by default be provided in either Java properties, YAML, JSON or Groovy files.
Configuration file example in YML :
```yml
kafka:
connections:
my-cluster-1:
properties:
bootstrap.servers: "kafka:9092"

registry: "https://schema-registry:8085"

my-cluster-2:
properties:
bootstrap.servers: "kafka:9093"
security.protocol: SSL
ssl.truststore.location: /app/truststore.jks
ssl.truststore.password: password
ssl.keystore.location: /app/keystore.jks
ssl.keystore.password: password
ssl.key.password: password
```
`kafka.connections` is a key value configuration with :
* `key`: must be an url friendly string the identify your cluster (`my-cluster-1` and `my-cluster-2` is the example above)
* `properties`: all the configurations found on [Kafka consumer documentation](https://kafka.apache.org/documentation/#consumerconfigs). Most important is `bootstrap.servers` that is a list of host:port of your Kafka brokers.
* `registry`: the schema registry url *(optional)*

KafkaHQ docker image support 1 environment variables to handle configuraiton :
* `KAFKAHQ_CONFIGURATION`: a string that contains the full configuration that will be written on /app/configuration.conf on container.
KafkaHQ docker image support 2 environment variables to handle configuraiton :
* `MICRONAUT_APPLICATION_JSON`: a string that contains the full configuration in JSON format
* `MICRONAUT_CONFIG_FILES`: a path to to a configuration file on container. Default path is `/app/application.yml`

More information can be found on [Micronaut documentation](https://docs.micronaut.io/snapshot/guide/index.html#config)

## Development Environment
A docker-compose is provide to start a development environnement.
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ task testKafkaCluster(type:JavaExec) {

task testInjectData(type:JavaExec) {
group = 'verification'
description = 'Start a standalone test Kafka cluster'
description = 'Inject data in a existing kafka cluster'
classpath sourceSets.test.runtimeClasspath
main = "org.kafkahq.KafkaTestCluster"
args ['inject']
args 'inject'
}

gradle.taskGraph.whenReady { graph ->
Expand Down
65 changes: 53 additions & 12 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
version: '3.6'

volumes:
gradle-cache:
driver: local

networks:
main: {}
zookeeper-data:
driver: local
kafka-data:
driver: local

services:
kafkahq:
image: gradle:4.10-jdk-alpine
command: "gradle --no-daemon joobyRun -x webpack"
environment:
application.host: "0.0.0.0"
application.env: "dev"
image: gradle:5.1.1-jdk-alpine
command: "gradle run --continuous"
working_dir: /app
volumes:
- ./:/app
- gradle-cache:/home/gradle/.gradle
ports:
- 127.11.8.17:8080:8080
networks:
- main
depends_on:
- kafka
- schema-registry

webpack:
image: node:11
Expand All @@ -30,5 +30,46 @@ services:
- ./:/app
ports:
- 127.11.8.17:8081:8081
networks:
- main
depends_on:
- kafkahq

zookeeper:
image: confluentinc/cp-zookeeper
volumes:
- zookeeper-data:/var/lib/zookeeper
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ports:
- 127.11.8.17:2181:2181

kafka:
image: confluentinc/cp-kafka
volumes:
- kafka-data:/var/lib/kafka
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_NUM_PARTITIONS: 12
KAFKA_COMPRESSION_TYPE: gzip
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT:https://kafka:9092
KAFKA_CONFLUENT_SUPPORT_METRICS.ENABLE: 'false'
KAFKA_JMX_PORT: 9091
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
links:
- zookeeper
ports:
- 127.11.8.17:9092:9092

schema-registry:
image: confluentinc/cp-schema-registry
depends_on:
- kafka
environment:
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: "PLAINTEXT:https://kafka:9092"
SCHEMA_REGISTRY_HOST_NAME: schema-registry
SCHEMA_REGISTRY_LISTENERS: "https://0.0.0.0:8085"
SCHEMA_REGISTRY_LOG4J_ROOT_LOGLEVEL: INFO
ports:
- 127.11.8.17:8085:8085
22 changes: 11 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ volumes:

services:
kafkahq:
image: tchiotludo/kafkahq
image: test
environment:
KAFKAHQ_CONFIGURATION: |
MICRONAUT_APPLICATION_JSON: |
{
kafka {
connections {
docker-kafka-server {
properties {
bootstrap.servers: "kafka:9092"
}
registry: "https://schema-registry:8085"
"kafka": {
"connections": {
"docker-kafka-server": {
"properties": {
"bootstrap.servers": "kafka:9092"
},
"registry": "https://schema-registry:8085"
}
}
}
Expand All @@ -27,6 +27,7 @@ services:
- 8080:8080
links:
- kafka
- schema-registry

zookeeper:
image: confluentinc/cp-zookeeper
Expand Down Expand Up @@ -56,7 +57,6 @@ services:
schema-registry:
image: confluentinc/cp-schema-registry
depends_on:
- zookeeper
- kafka
environment:
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: "PLAINTEXT:https://kafka:9092"
Expand All @@ -65,7 +65,7 @@ services:
SCHEMA_REGISTRY_LOG4J_ROOT_LOGLEVEL: INFO

test-data:
image: gradle:4.10-jdk
image: gradle:5.1.1-jdk
command: "gradle --no-daemon testInjectData"
working_dir: /app
volumes:
Expand Down
9 changes: 0 additions & 9 deletions docker/usr/local/bin/docker-entrypoint.sh

This file was deleted.

Loading

0 comments on commit 4bf2339

Please sign in to comment.