kavoru 0.7.1 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/features.ts +41 -29
package/package.json
CHANGED
package/src/features.ts
CHANGED
|
@@ -108,7 +108,7 @@ const FEATURE_PATHS: Record<FeatureId, string[]> = {
|
|
|
108
108
|
],
|
|
109
109
|
resend: ["src/infra/resend"],
|
|
110
110
|
cron: ["src/schedules"],
|
|
111
|
-
docker: ["
|
|
111
|
+
docker: ["docker-compose.yaml", "docker"],
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
const FEATURE_DEPENDENCIES: Partial<
|
|
@@ -510,7 +510,7 @@ async function patchEnvExample(
|
|
|
510
510
|
async function patchDockerfile(projectDir: string, selection: FeatureSelection) {
|
|
511
511
|
if (!selection.docker) return;
|
|
512
512
|
|
|
513
|
-
const relativePath = "Dockerfile";
|
|
513
|
+
const relativePath = "docker/app/Dockerfile";
|
|
514
514
|
const current = await readText(projectDir, relativePath);
|
|
515
515
|
if (!current) return;
|
|
516
516
|
|
|
@@ -530,19 +530,21 @@ async function patchDockerfile(projectDir: string, selection: FeatureSelection)
|
|
|
530
530
|
await writeText(projectDir, relativePath, content);
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
-
function
|
|
534
|
-
const lines = [
|
|
533
|
+
function buildDockerAppEnv(selection: FeatureSelection): string {
|
|
534
|
+
const lines = [
|
|
535
|
+
"# Docker-only overrides (loaded after root .env)",
|
|
536
|
+
"NODE_ENV=production",
|
|
537
|
+
];
|
|
535
538
|
if (selection.kafka) {
|
|
536
|
-
lines.push("
|
|
539
|
+
lines.push("KAFKA_BROKERS=kafka:9092");
|
|
537
540
|
}
|
|
538
541
|
if (selection.otel) {
|
|
539
|
-
lines.push("
|
|
540
|
-
lines.push(" OTEL_SERVICE_NAME: ${OTEL_SERVICE_NAME:-kavoru}");
|
|
542
|
+
lines.push("OTEL_EXPORTER_OTLP_ENDPOINT=http://otel:4318/v1/traces");
|
|
541
543
|
}
|
|
542
544
|
if (selection.sentry) {
|
|
543
|
-
lines.push("
|
|
545
|
+
lines.push("SENTRY_SPOTLIGHT=http://spotlight:8969/stream");
|
|
544
546
|
}
|
|
545
|
-
return
|
|
547
|
+
return `${lines.join("\n")}\n`;
|
|
546
548
|
}
|
|
547
549
|
|
|
548
550
|
function generateDockerCompose(selection: FeatureSelection): string {
|
|
@@ -552,29 +554,17 @@ function generateDockerCompose(selection: FeatureSelection): string {
|
|
|
552
554
|
condition: service_started
|
|
553
555
|
`
|
|
554
556
|
: "";
|
|
555
|
-
const appEnvironment = buildAppEnvironment(selection);
|
|
556
557
|
|
|
557
558
|
const kafkaService = selection.kafka
|
|
558
559
|
? `
|
|
559
560
|
kafka:
|
|
560
|
-
|
|
561
|
+
build:
|
|
562
|
+
context: docker/kafka
|
|
561
563
|
hostname: kafka
|
|
562
564
|
ports:
|
|
563
565
|
- "9094:9094"
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
KAFKA_NODE_ID: "0"
|
|
567
|
-
KAFKA_PROCESS_ROLES: broker,controller
|
|
568
|
-
KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
|
|
569
|
-
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,EXTERNAL://localhost:9094
|
|
570
|
-
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,EXTERNAL:PLAINTEXT
|
|
571
|
-
KAFKA_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093
|
|
572
|
-
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
|
|
573
|
-
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
|
574
|
-
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
|
575
|
-
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
|
|
576
|
-
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
|
|
577
|
-
KAFKA_LOG_DIRS: /tmp/kraft-combined-logs
|
|
566
|
+
env_file:
|
|
567
|
+
- docker/kafka/.env
|
|
578
568
|
networks:
|
|
579
569
|
- app_network
|
|
580
570
|
restart: unless-stopped
|
|
@@ -585,10 +575,11 @@ function generateDockerCompose(selection: FeatureSelection): string {
|
|
|
585
575
|
? `
|
|
586
576
|
otel:
|
|
587
577
|
build:
|
|
588
|
-
context:
|
|
589
|
-
dockerfile: docker/otel.Dockerfile
|
|
578
|
+
context: docker/otel
|
|
590
579
|
ports:
|
|
591
580
|
- "4318:4318"
|
|
581
|
+
env_file:
|
|
582
|
+
- docker/otel/.env
|
|
592
583
|
networks:
|
|
593
584
|
- app_network
|
|
594
585
|
restart: unless-stopped
|
|
@@ -598,9 +589,12 @@ function generateDockerCompose(selection: FeatureSelection): string {
|
|
|
598
589
|
const spotlightService = selection.sentry
|
|
599
590
|
? `
|
|
600
591
|
spotlight:
|
|
601
|
-
|
|
592
|
+
build:
|
|
593
|
+
context: docker/spotlight
|
|
602
594
|
ports:
|
|
603
595
|
- "8969:8969"
|
|
596
|
+
env_file:
|
|
597
|
+
- docker/spotlight/.env
|
|
604
598
|
networks:
|
|
605
599
|
- app_network
|
|
606
600
|
restart: unless-stopped
|
|
@@ -611,6 +605,7 @@ function generateDockerCompose(selection: FeatureSelection): string {
|
|
|
611
605
|
app:
|
|
612
606
|
build:
|
|
613
607
|
context: .
|
|
608
|
+
dockerfile: docker/app/Dockerfile
|
|
614
609
|
target: build
|
|
615
610
|
args:
|
|
616
611
|
PORT: \${PORT:-3131}
|
|
@@ -628,7 +623,8 @@ function generateDockerCompose(selection: FeatureSelection): string {
|
|
|
628
623
|
restart: unless-stopped
|
|
629
624
|
env_file:
|
|
630
625
|
- .env
|
|
631
|
-
|
|
626
|
+
- docker/app/.env
|
|
627
|
+
${appDependsOn} healthcheck:
|
|
632
628
|
test: ["CMD", "curl", "-f", "http://localhost:\${PORT}/healthz"]
|
|
633
629
|
interval: 600s
|
|
634
630
|
timeout: 300s
|
|
@@ -646,6 +642,22 @@ async function patchDockerCompose(
|
|
|
646
642
|
selection: FeatureSelection,
|
|
647
643
|
) {
|
|
648
644
|
if (!selection.docker) return;
|
|
645
|
+
|
|
646
|
+
if (!selection.kafka) {
|
|
647
|
+
await removePaths(projectDir, ["docker/kafka"]);
|
|
648
|
+
}
|
|
649
|
+
if (!selection.otel) {
|
|
650
|
+
await removePaths(projectDir, ["docker/otel"]);
|
|
651
|
+
}
|
|
652
|
+
if (!selection.sentry) {
|
|
653
|
+
await removePaths(projectDir, ["docker/spotlight"]);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
await writeText(
|
|
657
|
+
projectDir,
|
|
658
|
+
"docker/app/.env",
|
|
659
|
+
buildDockerAppEnv(selection),
|
|
660
|
+
);
|
|
649
661
|
await writeText(projectDir, "docker-compose.yaml", generateDockerCompose(selection));
|
|
650
662
|
}
|
|
651
663
|
|