Skip to content

Commit

Permalink
use node
Browse files Browse the repository at this point in the history
  • Loading branch information
mbund committed Dec 1, 2023
1 parent 34c15cf commit d933937
Show file tree
Hide file tree
Showing 7 changed files with 1,111 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
out
.env
kubeconfig.yaml
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
FROM oven/bun:1-slim
FROM node:20-alpine as builder

RUN npm install -g pnpm

WORKDIR /app
COPY package.json bun.lockb ./
COPY package.json pnpm-lock.yaml ./

RUN bun install
RUN pnpm install

COPY index.ts .

CMD ["bun", "start"]
RUN pnpm build

FROM node:20-alpine as runner

WORKDIR /app
COPY --from=builder /app/out/index.js index.js

CMD ["node", "index.js"]
Binary file removed bun.lockb
Binary file not shown.
9 changes: 7 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ import {
GatewayIntentBits,
GuildMemberRoleManager,
} from "discord.js";
import k8s from "@kubernetes/client-node";
import * as k8s from "@kubernetes/client-node";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import relativeTime from "dayjs/plugin/relativeTime";
import { randomBytes } from "node:crypto";
import { config } from "dotenv";

config();

dayjs.extend(duration);
dayjs.extend(relativeTime);
Expand Down Expand Up @@ -373,6 +376,8 @@ cert: false
const endTime = new Date(new Date().getTime() + workspaceDuration);
warnFn(endTime);

console.log(`Created workspace for ${interaction.user.globalName}`);

await interaction.editReply({
content: `Workspace created! It will expire <t:${Math.floor(
endTime.getTime() / 1000
Expand Down Expand Up @@ -467,4 +472,4 @@ client.on(Events.InteractionCreate, async (interaction) => {
}
});

client.login(Bun.env.DISCORD_BOT_TOKEN);
client.login(process.env.DISCORD_BOT_TOKEN);
29 changes: 17 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
{
"name": "workspace-bot",
"module": "index.ts",
"type": "module",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "bun run --watch index.ts",
"start": "bun run index.ts"
},
"devDependencies": {
"bun-types": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
"dev": "tsx watch index.ts",
"build": "esbuild index.ts --bundle --platform=node --outdir=out",
"start": "node out"
},
"keywords": [],
"author": "",
"license": "GPL-3.0-only",
"dependencies": {
"@kubernetes/client-node": "next",
"@kubernetes/client-node": "1.0.0-rc3",
"dayjs": "^1.11.10",
"discord.js": "^14.14.1"
"discord.js": "^14.14.1",
"dotenv": "^16.3.1"
},
"devDependencies": {
"esbuild": "^0.19.8",
"tsx": "^4.6.1",
"typescript": "^5.3.2"
}
}
Loading

0 comments on commit d933937

Please sign in to comment.