perf: optimize Docker images - backend 294MB, gateway 1.89GB
Build & Deploy / build-and-push (backend) (push) Failing after 1m25s
Build & Deploy / build-and-push (discord-gateway) (push) Failing after 26s
Build & Deploy / build-and-push (proxy) (push) Failing after 25s
Build & Deploy / build-and-push (backend) (push) Failing after 1m25s
Build & Deploy / build-and-push (discord-gateway) (push) Failing after 26s
Build & Deploy / build-and-push (proxy) (push) Failing after 25s
Backend: - node:22-alpine runtime (from 1.82GB to 294MB, 84% reduction) - COPY --chown instead of chown -R layer - pnpm install --prod after build for clean .pnpm store - Pinned pnpm@10 to avoid v11 build-script lockout Gateway: - Fixed TypeScript errors (missing table defs in shared schema) - Restored node-crc Rust patch for native compilation - Multi-stage build with COPY --chown - pnpm install --prod after build - ffmpeg with --no-install-recommends Proxy: - Restructured for standalone build (build errors are pre-existing) General: - pnpm@10 in all builds (avoids ERR_PNPM_IGNORED_BUILDS) - Clean .dockerignore (excludes docs/design/scripts)
This commit is contained in:
@@ -4,7 +4,20 @@
|
||||
"description": "Discord Gateway service - handles message capture, voice recording, and AI moderation",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"packageManager": "pnpm@11.1.3",
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"@discordjs/opus",
|
||||
"@lng2004/node-datachannel",
|
||||
"esbuild",
|
||||
"node-av",
|
||||
"node-crc",
|
||||
"sharp",
|
||||
"zeromq"
|
||||
],
|
||||
"patchedDependencies": {
|
||||
"node-crc@4.0.0": "./patches/node-crc@4.0.0.patch"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"start": "node dist/index.js",
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
diff --git a/Cargo.toml b/Cargo.toml
|
||||
index a967508960d8b6b686b23401ea14333b858a675c..d0282a30ee931563a65d774ed783c83d6d2fdd5e 100644
|
||||
--- a/Cargo.toml
|
||||
+++ b/Cargo.toml
|
||||
@@ -3,7 +3,7 @@ name = "node-crc"
|
||||
version = "4.0.0"
|
||||
authors = ["Magic Len <len@magiclen.org>"]
|
||||
edition = "2021"
|
||||
-rust-version = "1.65"
|
||||
+rust-version = "1.77.0"
|
||||
repository = "https://github.com/magiclen/node-crc"
|
||||
homepage = "https://magiclen.org/node-js-crc/"
|
||||
keywords = ["nodejs", "crc8", "crc16", "crc32", "crc64"]
|
||||
@@ -594,3 +594,103 @@ export type DbRetentionPolicyInsert =
|
||||
export type ChatbotMessage = typeof chatbotMessagesTable.$inferSelect;
|
||||
export type ChatbotMessageInsert =
|
||||
typeof chatbotMessagesTable.$inferInsert;
|
||||
|
||||
// =============================================================================
|
||||
// Moderation Actions (gateway-local)
|
||||
// =============================================================================
|
||||
|
||||
export const pgModerationActionsTable = pgTable(
|
||||
"moderation_actions",
|
||||
{
|
||||
id: pgText("id").primaryKey(),
|
||||
message_id: pgText("message_id"),
|
||||
user_id: pgText("user_id"),
|
||||
guild_id: pgText("guild_id").notNull(),
|
||||
action_type: pgText("action_type", {
|
||||
enum: [
|
||||
"delete_message",
|
||||
"mute_user",
|
||||
"warn_user",
|
||||
"kick_user",
|
||||
"ban_user",
|
||||
],
|
||||
}).notNull(),
|
||||
reason: pgText("reason"),
|
||||
executed_by: pgText("executed_by"),
|
||||
status: pgText("status", {
|
||||
enum: ["pending", "executed", "failed"],
|
||||
})
|
||||
.notNull()
|
||||
.default("pending"),
|
||||
error: pgText("error"),
|
||||
created_at: pgBigint("created_at", { mode: "number" }).notNull(),
|
||||
executed_at: pgBigint("executed_at", { mode: "number" }),
|
||||
},
|
||||
(table) => ({
|
||||
messageIdIdx: pgIndex("idx_moderation_actions_message_id").on(
|
||||
table.message_id,
|
||||
),
|
||||
userIdIdx: pgIndex("idx_moderation_actions_user_id").on(table.user_id),
|
||||
statusIdx: pgIndex("idx_moderation_actions_status").on(table.status),
|
||||
guildStatusIdx: pgIndex("idx_moderation_actions_guild_status").on(
|
||||
table.guild_id,
|
||||
table.status,
|
||||
table.created_at,
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
export const moderationActionsTable = pgModerationActionsTable;
|
||||
|
||||
// =============================================================================
|
||||
// Message Edits (gateway-local)
|
||||
// =============================================================================
|
||||
|
||||
export const pgMessageEditsTable = pgTable(
|
||||
"message_edits",
|
||||
{
|
||||
id: pgUuid("id").defaultRandom().primaryKey(),
|
||||
message_id: pgText("message_id").notNull(),
|
||||
old_content: pgText("old_content").notNull(),
|
||||
edited_at: pgBigint("edited_at", { mode: "number" }).notNull(),
|
||||
},
|
||||
(table) => ({
|
||||
messageIdIdx: pgIndex("idx_message_edits_message_id").on(table.message_id),
|
||||
editedAtIdx: pgIndex("idx_message_edits_edited_at").on(table.edited_at),
|
||||
}),
|
||||
);
|
||||
|
||||
export const messageEditsTable = pgMessageEditsTable;
|
||||
|
||||
// =============================================================================
|
||||
// Reactions (gateway-local)
|
||||
// =============================================================================
|
||||
|
||||
export const pgReactionsTable = pgTable(
|
||||
"message_reactions",
|
||||
{
|
||||
id: pgText("id").primaryKey(),
|
||||
message_id: pgText("message_id").notNull(),
|
||||
channel_id: pgText("channel_id").notNull(),
|
||||
guild_id: pgText("guild_id").notNull(),
|
||||
user_id: pgText("user_id").notNull(),
|
||||
username: pgText("username").notNull(),
|
||||
emoji: pgText("emoji").notNull(),
|
||||
emoji_id: pgText("emoji_id"),
|
||||
animated: pgBoolean("animated").notNull().default(false),
|
||||
reaction_type: pgText("reaction_type", {
|
||||
enum: ["add", "remove"],
|
||||
}).notNull(),
|
||||
created_at: pgBigint("created_at", { mode: "number" }).notNull(),
|
||||
},
|
||||
(table) => ({
|
||||
messageIdIdx: pgIndex("idx_reactions_message_id").on(table.message_id),
|
||||
userIdIdx: pgIndex("idx_reactions_user_id").on(table.user_id),
|
||||
guildCreatedIdx: pgIndex("idx_reactions_guild_created").on(
|
||||
table.guild_id,
|
||||
table.created_at,
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
export const reactionsTable = pgReactionsTable;
|
||||
|
||||
Reference in New Issue
Block a user