feat(build): optimize Dockerfile to build vendor packages during image build and streamline package.json scripts

This commit is contained in:
Asep Haryana Saputra
2026-05-21 12:27:07 +00:00
parent 0530bf9a60
commit 41197fd2c2
8 changed files with 83 additions and 19 deletions
+7 -3
View File
@@ -1,7 +1,11 @@
import { AppError } from "../errors.js";
import { createChildLogger } from "../logger.js";
import { discordPlayer } from "../player.js";
import { playPreparedStream, Streamer } from "../streaming/index.js";
import {
playPreparedStream,
playTranscodedPreparedStream,
Streamer,
} from "../streaming/index.js";
const logger = createChildLogger("screen-share");
@@ -105,8 +109,8 @@ export function createScreenShareController(
let stopped = false;
const playFn = dependencies.useTranscoder
? (await import("../streaming/index.js")).playTranscodedPreparedStream
: (await import("../streaming/index.js")).playPreparedStream;
? playTranscodedPreparedStream
: playPreparedStream;
const done = playFn(directUrl, session, {
fps: 30,
+21 -4
View File
@@ -1,3 +1,5 @@
import { existsSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { Worker } from "node:worker_threads";
import { config } from "../config.js";
import { createChildLogger } from "../logger.js";
@@ -157,15 +159,30 @@ async function processBatch(
}
}
function getAnalysisWorkerUrl(): URL {
const candidates = [
new URL("./aiAnalysisWorker.js", import.meta.url),
new URL("../aiAnalysisWorker.js", import.meta.url),
new URL("./aiAnalysisWorker.ts", import.meta.url),
];
for (const candidate of candidates) {
if (existsSync(fileURLToPath(candidate))) {
return candidate;
}
}
return candidates[2];
}
async function runAnalysisInWorker(
conversationKey: string,
messages: MessageRecord[],
): Promise<AnalysisWorkerResponse> {
return new Promise((resolve, reject) => {
const worker = new Worker(
new URL("./aiAnalysisWorker.js", import.meta.url),
{ execArgv: process.execArgv },
);
const worker = new Worker(getAnalysisWorkerUrl(), {
execArgv: process.execArgv,
});
worker.once("message", (response: AnalysisWorkerResponse) => {
worker.terminate().catch((error) => {
+5 -1
View File
@@ -2,7 +2,11 @@ import OpenAI from "openai";
import { config } from "../config.js";
import { createChildLogger } from "../logger.js";
import { retryWithBackoff } from "../retry.js";
import type { AnalysisResult, AttachmentRecord, MessageRecord } from "./types.js";
import type {
AnalysisResult,
AttachmentRecord,
MessageRecord,
} from "./types.js";
const log = createChildLogger("llmModerationClient");
const openai = new OpenAI({
+4 -1
View File
@@ -1,4 +1,7 @@
import type { BroadcasterClient, ModerationBroadcaster } from "./broadcaster.js";
import type {
BroadcasterClient,
ModerationBroadcaster,
} from "./broadcaster.js";
export type AIStatus = "pending" | "clean" | "warn" | "flagged" | "error";
+4 -1
View File
@@ -2,7 +2,10 @@ import { ChildProcess, spawn } from "node:child_process";
import type { Readable } from "node:stream";
import { PassThrough } from "node:stream";
import { createChildLogger } from "../logger.js";
import { transcoderRestartsCounter, transcoderRunningGauge } from "../metrics.js";
import {
transcoderRestartsCounter,
transcoderRunningGauge,
} from "../metrics.js";
import { retryWithBackoff } from "../retry.js";
const logger = createChildLogger("transcoder");