Set up deployment

This commit is contained in:
2026-08-22 19:50:35 -04:00
parent 4bd77fad8a
commit 2982c1ee99
4 changed files with 21 additions and 5 deletions
+9 -3
View File
@@ -7,11 +7,17 @@ WORKDIR /app
COPY package.json bun.lock ./ COPY package.json bun.lock ./
RUN bun install --frozen-lockfile --production RUN bun install --frozen-lockfile --production
FROM oven/bun:1-alpine AS runner FROM oven/bun:1-alpine AS builder
WORKDIR /app WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY tsconfig.json ./ COPY package.json tsconfig.json ./
COPY src ./src COPY src ./src
RUN bun run build
FROM oven/bun:1-alpine AS runner
WORKDIR /app
COPY --from=builder /app/dist ./dist
USER bun USER bun
CMD ["bun", "src/index.ts"] CMD ["bun", "dist/index.js"]
Executable
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
fly secrets import --stage < .env.production
fly deploy
+2 -1
View File
@@ -6,7 +6,8 @@
"@types/node": "^25.9.5" "@types/node": "^25.9.5"
}, },
"scripts": { "scripts": {
"dev": "bun run src/index.ts" "dev": "bun run src/index.ts",
"build": "bun build ./src/index.ts $(find src/cmd/registry -name \"*.ts\") --target bun --minify --splitting --root src --outdir ./dist"
}, },
"peerDependencies": { "peerDependencies": {
"typescript": "^5.9.3" "typescript": "^5.9.3"
+3 -1
View File
@@ -1,15 +1,17 @@
import type { Message } from "discord.js"; import type { Message } from "discord.js";
import { readdir } from "fs/promises"; import { readdir } from "fs/promises";
import { dirname } from "path";
import type { Command } from "../models"; import type { Command } from "../models";
const CMD_PREFIX = "."; const CMD_PREFIX = ".";
const CMD_REGISTRY_DIR = `${dirname(Bun.main)}/cmd/registry`;
export default abstract class CommandService { export default abstract class CommandService {
private static registry: Record<string, Command> = {} private static registry: Record<string, Command> = {}
static async init() { static async init() {
const commands = await Promise.all( const commands = await Promise.all(
(await readdir(`${import.meta.dir}/../cmd/registry`)).map(async file => (await import(`../cmd/registry/${file}`)).default satisfies Command) (await readdir(CMD_REGISTRY_DIR)).map(async file => (await import(`${CMD_REGISTRY_DIR}/${file}`)).default satisfies Command)
); );
for (const command of commands) for (const command of commands)
CommandService.registry[command.name] = command; CommandService.registry[command.name] = command;