Add dockerfile
This commit is contained in:
parent
dcf0853e20
commit
12397abf5a
16 changed files with 3332 additions and 2363 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
dist
|
dist
|
||||||
node_modules
|
node_modules
|
||||||
|
cache
|
||||||
.env
|
.env
|
||||||
.git
|
.git
|
||||||
.trash
|
.trash
|
||||||
|
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -7,3 +7,4 @@ packages/generated
|
||||||
|
|
||||||
.env
|
.env
|
||||||
cache
|
cache
|
||||||
|
docker-compose.yml
|
||||||
|
|
|
||||||
18
Dockerfile
18
Dockerfile
|
|
@ -1,9 +1,19 @@
|
||||||
FROM node:24-slim
|
FROM node:24-slim AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN --mount=type=cache,target=/root/.npm,sharing=locked npm ci --include=dev
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run init
|
RUN npm run build
|
||||||
|
|
||||||
CMD [ "node", "dist" ]
|
FROM node:24-slim AS app
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
COPY --from=builder /app/dist ./
|
||||||
|
RUN --mount=type=cache,target=/root/.npm,sharing=locked npm ci --include=prod
|
||||||
|
|
||||||
|
CMD [ "npm", "start" ]
|
||||||
|
|
|
||||||
32
docker-compose-example.yml
Normal file
32
docker-compose-example.yml
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
networks:
|
||||||
|
discord-bot-internal:
|
||||||
|
internal: true
|
||||||
|
discord-bot-external:
|
||||||
|
internal: false
|
||||||
|
|
||||||
|
services:
|
||||||
|
discord-bot:
|
||||||
|
build: .
|
||||||
|
container_name: discord_bot
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- discord-bot-internal
|
||||||
|
- discord-bot-external
|
||||||
|
environment:
|
||||||
|
DISCORD_TOKEN: "${DISCORD_TOKEN}"
|
||||||
|
APPLICATION_ID: "${APPLICATION_ID}"
|
||||||
|
GUILD_ID: "${GUILD_ID}"
|
||||||
|
TYPECAST_TOKEN: "${TYPECAST_TOKEN}"
|
||||||
|
DATABASE_URL: "postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@$discord-db:5432/${POSTGRES_DB}?schema=public"
|
||||||
|
discord-db:
|
||||||
|
container_name: discord-db
|
||||||
|
image: postgres:17
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- discord-bot-internal
|
||||||
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
|
||||||
|
POSTGRES_USER: "${POSTGRES_USER}"
|
||||||
|
POSTGRES_DB: "${POSTGRES_DB}"
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
services:
|
|
||||||
discord-bot:
|
|
||||||
build: .
|
|
||||||
environment:
|
|
||||||
- DISCORD_TOKEN=MTQ2MDU5NTMyMzczODI2MzU3Mg.Gn2Mn-.dIRJ9MGKRs9mmUkDbDpZ4h_NSjiNVquKk9VPpo
|
|
||||||
- APPLICATION_ID=1460595323738263572
|
|
||||||
- TYPECAST_TOKEN=__pltP9LVqfCqTGAk353JZsEKey49ivoWw799Lp9CM7Ru
|
|
||||||
- DATABASE_URL=postgresql://yaeju:251205Yaeji@localhost:5432/discord_bot?schema=public
|
|
||||||
db:
|
|
||||||
image: postgres:17
|
|
||||||
restart: always
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: yaejy
|
|
||||||
POSTGRES_PASSWORD: 251205Yaeji
|
|
||||||
POSTGRES_DB: yaejudb
|
|
||||||
ports:
|
|
||||||
- "5432:5432"
|
|
||||||
volumes:
|
|
||||||
- postgres_data:/var/lib/postgresql/data
|
|
||||||
3221
package-lock.json
generated
Normal file
3221
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
14
package.json
14
package.json
|
|
@ -1,9 +1,14 @@
|
||||||
{
|
{
|
||||||
|
"main": "dist",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"init": "prisma db push && npm run build",
|
"prisma:push": "prisma db push",
|
||||||
"prismabuild": "prisma format && prisma generate",
|
"format:prisma": "prisma format",
|
||||||
"build": "npm run prismabuild && tsc",
|
"format": "npm run format:prisma",
|
||||||
"start": "npm run build && node dist"
|
"build:prisma": "prisma generate",
|
||||||
|
"build:tsc": "tsc",
|
||||||
|
"build": "npm run build:tsc && npm run build:prisma",
|
||||||
|
"start": "node .",
|
||||||
|
"dev": "npm run build && npm run start"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/opus": "^0.10.0",
|
"@discordjs/opus": "^0.10.0",
|
||||||
|
|
@ -20,7 +25,6 @@
|
||||||
"opusscript": "^0.0.8",
|
"opusscript": "^0.0.8",
|
||||||
"pg": "^8.17.1",
|
"pg": "^8.17.1",
|
||||||
"play-dl": "^1.9.7",
|
"play-dl": "^1.9.7",
|
||||||
"pnpm": "^10.28.0",
|
|
||||||
"prism-media": "^1.3.5",
|
"prism-media": "^1.3.5",
|
||||||
"prisma": "^7.2.0",
|
"prisma": "^7.2.0",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ export async function playVoice(guild: Guild, profile: DiscordUserProfile, text:
|
||||||
if (profile.canTypecast) {
|
if (profile.canTypecast) {
|
||||||
voiceBuffer = await createVoiceBuffer(profile.voice, text);
|
voiceBuffer = await createVoiceBuffer(profile.voice, text);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`the user ${profile.userId} is not admin`);
|
throw new Error(`the user ${profile.userId} is can't use typecast voice`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
voiceBuffer = await createVoiceBuffer(profile.voice, text);
|
voiceBuffer = await createVoiceBuffer(profile.voice, text);
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@ import type * as Prisma from "./prismaNamespace"
|
||||||
|
|
||||||
const config: runtime.GetPrismaClientConfig = {
|
const config: runtime.GetPrismaClientConfig = {
|
||||||
"previewFeatures": [],
|
"previewFeatures": [],
|
||||||
"clientVersion": "7.2.0",
|
"clientVersion": "7.3.0",
|
||||||
"engineVersion": "0c8ef2ce45c83248ab3df073180d5eda9e8be7a3",
|
"engineVersion": "9d6ad21cbbceab97458517b147a6a09ff43aa735",
|
||||||
"activeProvider": "postgresql",
|
"activeProvider": "postgresql",
|
||||||
"inlineSchema": "// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\n// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?\n// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init\n\ngenerator client {\n provider = \"prisma-client\"\n specifying = [\"prismaSchemaFolder\"]\n output = \"../packages/db/generated/prisma\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n}\n\nenum Voice {\n TypeCast\n Papago\n}\n\nmodel DiscordUserProfile {\n id String @id @default(cuid())\n userId String @unique\n voice Voice @default(Papago)\n nya Boolean @default(false)\n canTypecast Boolean @default(false)\n}\n\nmodel DiscordGuildProfile {\n id String @id @default(cuid())\n guildId String @unique\n readChannel String[] @default([])\n}\n",
|
"inlineSchema": "generator client {\n provider = \"prisma-client\"\n output = \"../packages/db/generated/prisma\"\n specifying = [\"prismaSchemaFolder\"]\n}\n\ndatasource db {\n provider = \"postgresql\"\n}\n\nmodel DiscordUserProfile {\n id String @id @default(cuid())\n userId String @unique\n voice Voice @default(Papago)\n nya Boolean @default(false)\n canTypecast Boolean @default(false)\n}\n\nmodel DiscordGuildProfile {\n id String @id @default(cuid())\n guildId String @unique\n readChannel String[] @default([])\n}\n\nenum Voice {\n TypeCast\n Papago\n}\n",
|
||||||
"runtimeDataModel": {
|
"runtimeDataModel": {
|
||||||
"models": {},
|
"models": {},
|
||||||
"enums": {},
|
"enums": {},
|
||||||
|
|
@ -37,12 +37,14 @@ async function decodeBase64AsWasm(wasmBase64: string): Promise<WebAssembly.Modul
|
||||||
}
|
}
|
||||||
|
|
||||||
config.compilerWasm = {
|
config.compilerWasm = {
|
||||||
getRuntime: async () => await import("@prisma/client/runtime/query_compiler_bg.postgresql.js"),
|
getRuntime: async () => await import("@prisma/client/runtime/query_compiler_fast_bg.postgresql.js"),
|
||||||
|
|
||||||
getQueryCompilerWasmModule: async () => {
|
getQueryCompilerWasmModule: async () => {
|
||||||
const { wasm } = await import("@prisma/client/runtime/query_compiler_bg.postgresql.wasm-base64.js")
|
const { wasm } = await import("@prisma/client/runtime/query_compiler_fast_bg.postgresql.wasm-base64.js")
|
||||||
return await decodeBase64AsWasm(wasm)
|
return await decodeBase64AsWasm(wasm)
|
||||||
}
|
},
|
||||||
|
|
||||||
|
importName: "./query_compiler_fast_bg.js"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,12 +80,12 @@ export type PrismaVersion = {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prisma Client JS version: 7.2.0
|
* Prisma Client JS version: 7.3.0
|
||||||
* Query Engine version: 0c8ef2ce45c83248ab3df073180d5eda9e8be7a3
|
* Query Engine version: 9d6ad21cbbceab97458517b147a6a09ff43aa735
|
||||||
*/
|
*/
|
||||||
export const prismaVersion: PrismaVersion = {
|
export const prismaVersion: PrismaVersion = {
|
||||||
client: "7.2.0",
|
client: "7.3.0",
|
||||||
engine: "0c8ef2ce45c83248ab3df073180d5eda9e8be7a3"
|
engine: "9d6ad21cbbceab97458517b147a6a09ff43aa735"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -61,12 +61,12 @@ export type ModelName = (typeof ModelName)[keyof typeof ModelName]
|
||||||
* Enums
|
* Enums
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const TransactionIsolationLevel = {
|
export const TransactionIsolationLevel = runtime.makeStrictEnum({
|
||||||
ReadUncommitted: 'ReadUncommitted',
|
ReadUncommitted: 'ReadUncommitted',
|
||||||
ReadCommitted: 'ReadCommitted',
|
ReadCommitted: 'ReadCommitted',
|
||||||
RepeatableRead: 'RepeatableRead',
|
RepeatableRead: 'RepeatableRead',
|
||||||
Serializable: 'Serializable'
|
Serializable: 'Serializable'
|
||||||
} as const
|
} as const)
|
||||||
|
|
||||||
export type TransactionIsolationLevel = (typeof TransactionIsolationLevel)[keyof typeof TransactionIsolationLevel]
|
export type TransactionIsolationLevel = (typeof TransactionIsolationLevel)[keyof typeof TransactionIsolationLevel]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
import { Response as NodeFetchResponse, RequestInit, RequestInfo } from "node-fetch";
|
export default async function(url: URL | RequestInfo, request: RequestInit={}, time: number=5000): Promise<Response> {
|
||||||
import defaultFetch from "node-fetch";
|
|
||||||
|
|
||||||
export default async function(url: URL | RequestInfo, request: RequestInit={}, time: number=5000): Promise<NodeFetchResponse | Response> {
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeout = setTimeout(() => controller.abort(), time);
|
const timeout = setTimeout(() => controller.abort(), time);
|
||||||
|
|
||||||
request.signal ??= controller.signal;
|
request.signal ??= controller.signal;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await defaultFetch(url, request);;
|
return await fetch(url, request);;
|
||||||
} finally {
|
} finally {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2305
pnpm-lock.yaml
2305
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
28
prisma/migrations/20260209195454_init_migrate/migration.sql
Normal file
28
prisma/migrations/20260209195454_init_migrate/migration.sql
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
-- CreateEnum
|
||||||
|
CREATE TYPE "Voice" AS ENUM ('TypeCast', 'Papago');
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "DiscordUserProfile" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"voice" "Voice" NOT NULL DEFAULT 'Papago',
|
||||||
|
"nya" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"canTypecast" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
|
||||||
|
CONSTRAINT "DiscordUserProfile_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "DiscordGuildProfile" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"guildId" TEXT NOT NULL,
|
||||||
|
"readChannel" TEXT[] DEFAULT ARRAY[]::TEXT[],
|
||||||
|
|
||||||
|
CONSTRAINT "DiscordGuildProfile_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "DiscordUserProfile_userId_key" ON "DiscordUserProfile"("userId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "DiscordGuildProfile_guildId_key" ON "DiscordGuildProfile"("guildId");
|
||||||
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Please do not edit this file manually
|
||||||
|
# It should be added in your version-control system (e.g., Git)
|
||||||
|
provider = "postgresql"
|
||||||
|
|
@ -1,24 +1,13 @@
|
||||||
// This is your Prisma schema file,
|
|
||||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
||||||
|
|
||||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
||||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
||||||
|
|
||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client"
|
provider = "prisma-client"
|
||||||
specifying = ["prismaSchemaFolder"]
|
|
||||||
output = "../packages/db/generated/prisma"
|
output = "../packages/db/generated/prisma"
|
||||||
|
specifying = ["prismaSchemaFolder"]
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
provider = "postgresql"
|
provider = "postgresql"
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Voice {
|
|
||||||
TypeCast
|
|
||||||
Papago
|
|
||||||
}
|
|
||||||
|
|
||||||
model DiscordUserProfile {
|
model DiscordUserProfile {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
userId String @unique
|
userId String @unique
|
||||||
|
|
@ -32,3 +21,8 @@ model DiscordGuildProfile {
|
||||||
guildId String @unique
|
guildId String @unique
|
||||||
readChannel String[] @default([])
|
readChannel String[] @default([])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Voice {
|
||||||
|
TypeCast
|
||||||
|
Papago
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue