chore: Provide scripts to start the containers

This commit is contained in:
Alexander Kobjolke 2024-11-09 23:14:19 +01:00
parent 24795af52b
commit 06aab542bf
4 changed files with 39 additions and 15 deletions

View file

@ -52,33 +52,36 @@
''; '';
"distributed-portal".exec = '' "distributed-portal".exec = ''
java ${datasource}/distributed-besucherportal \ java ${datasource}/distributed-besucherportal \
-Dbootstrap.servers=localhost:29092 \ -Dbootstrap.servers=localhost:9092 \
-Dspring.kafka.consumer.bootstrap-servers=localhost:29092 \ -Dspring.kafka.consumer.bootstrap-servers=localhost:9092 \
-Dspring.kafka.producer.bootstrap-servers=localhost:29092 \ -Dspring.kafka.producer.bootstrap-servers=localhost:9092 \
-jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-besucherportal/target/flexinale-distributed-besucherportal-2024.3.0-spring-boot-fat-jar.jar -jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-besucherportal/target/flexinale-distributed-besucherportal-2024.3.0-spring-boot-fat-jar.jar
''; '';
"distributed-backoffice".exec = '' "distributed-backoffice".exec = ''
java ${datasource}/distributed-backoffice \ java ${datasource}/distributed-backoffice \
-Dbootstrap.servers=localhost:29092 \ -Dbootstrap.servers=localhost:9092 \
-Dspring.kafka.consumer.bootstrap-servers=localhost:29092 \ -Dspring.kafka.consumer.bootstrap-servers=localhost:9092 \
-Dspring.kafka.producer.bootstrap-servers=localhost:29092 \ -Dspring.kafka.producer.bootstrap-servers=localhost:9092 \
-jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-backoffice/target/flexinale-distributed-backoffice-2024.3.0-spring-boot-fat-jar.jar -jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-backoffice/target/flexinale-distributed-backoffice-2024.3.0-spring-boot-fat-jar.jar
''; '';
"distributed-ticketing".exec = '' "distributed-ticketing".exec = ''
java ${datasource}/distributed-ticketing \ java ${datasource}/distributed-ticketing \
-Dbootstrap.servers=localhost:29092 \ -Dbootstrap.servers=localhost:9092 \
-Dspring.kafka.consumer.bootstrap-servers=localhost:29092 \ -Dspring.kafka.consumer.bootstrap-servers=localhost:9092 \
-Dspring.kafka.producer.bootstrap-servers=localhost:29092 \ -Dspring.kafka.producer.bootstrap-servers=localhost:9092 \
-jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-ticketing/target/flexinale-distributed-ticketing-2024.3.0-spring-boot-fat-jar.jar -jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-ticketing/target/flexinale-distributed-ticketing-2024.3.0-spring-boot-fat-jar.jar
''; '';
}; };
services.apache-kafka = { services.kafka = {
enable = true; enable = true;
clusterId = "foobar"; clusterId = "foobar";
settings = { settings = {
"broker.id" = 1; "broker.id" = 1;
"node.id" = 1; "node.id" = 1;
"offsets.topic.replication.factor" = 1;
"transaction.state.log.replication.factor" = 1;
"transaction.state.log.min.isr" = 1;
"process.roles" = [ "process.roles" = [
"broker" "broker"
"controller" "controller"

View file

@ -0,0 +1,12 @@
#!/usr/bin/env sh
podman-compose \
--project-name flexinale-distributed \
-f ../../../infrastructure/docker/flexinale-network.yml \
-f ../../../infrastructure/docker/postgres/flexinale-postgres.yml \
-f ../../../infrastructure/docker/kafka/flexinale-kafka-1-zookeeper.yml \
-f ../../../infrastructure/docker/kafka/flexinale-kafka-2-kafka.yml \
-f ../../../infrastructure/docker/kafka/flexinale-kafka-3-kafdrop.yml \
-f flexinale-distributed-besucherportal.yml \
-f flexinale-distributed-ticketing.yml \
-f flexinale-distributed-backoffice.yml \
up

View file

@ -0,0 +1,9 @@
#!/usr/bin/env sh
podman-compose \
--project-name flexinale \
-f flexinale-network.yml \
-f postgres/flexinale-postgres.yml \
-f kafka/flexinale-kafka-1-zookeeper.yml \
-f kafka/flexinale-kafka-2-kafka.yml \
-f kafka/flexinale-kafka-3-kafdrop.yml \
up

View file

@ -5,7 +5,7 @@
... ...
}: }:
let let
cfg = config.services.apache-kafka; cfg = config.services.kafka;
# The `javaProperties` generator takes care of various escaping rules and # The `javaProperties` generator takes care of various escaping rules and
# generation of the properties file, but we'll handle stringly conversion # generation of the properties file, but we'll handle stringly conversion
@ -56,7 +56,7 @@ let
''; '';
in in
{ {
options.services.apache-kafka = { options.services.kafka = {
enable = lib.mkEnableOption "Apache Kafka event streaming broker"; enable = lib.mkEnableOption "Apache Kafka event streaming broker";
settings = lib.mkOption { settings = lib.mkOption {
@ -100,7 +100,7 @@ in
See [listeners](https://kafka.apache.org/documentation/#brokerconfigs_listeners). See [listeners](https://kafka.apache.org/documentation/#brokerconfigs_listeners).
''; '';
type = lib.types.listOf lib.types.str; type = lib.types.listOf lib.types.str;
default = [ "PLAINTEXT://localhost:29092" ]; default = [ "PLAINTEXT://localhost:9092" ];
}; };
}; };
}; };
@ -181,13 +181,13 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.apache-kafka.configFiles.serverProperties = generator "server.properties" stringlySettings; services.kafka.configFiles.serverProperties = generator "server.properties" stringlySettings;
scripts.kaf.exec = '' scripts.kaf.exec = ''
exec ${pkgs.kaf}/bin/kaf --config ${kafConfig} "$@" exec ${pkgs.kaf}/bin/kaf --config ${kafConfig} "$@"
''; '';
processes.apache-kafka = { processes.kafka = {
exec = "${startScript}"; exec = "${startScript}";
# process-compose = { # process-compose = {