summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Magnusson <mathias@magnusson.space>2026-01-21 16:25:43 +0100
committerMathias Magnusson <mathias@magnusson.space>2026-01-21 16:29:00 +0100
commit1539287cd123a604de23bc31a4abb0fdfce2a093 (patch)
tree97577b2c5db1d2e66a956ad3f84d0d2d95f37a8b
parent0f28dfc85127badd5333bf99060a905835aac224 (diff)
downloadchalle-anka-1539287cd123a604de23bc31a4abb0fdfce2a093.tar.gz
create Dockerfile & compose.yaml
-rw-r--r--Dockerfile19
-rw-r--r--compose.yaml6
-rw-r--r--index.ts15
3 files changed, 30 insertions, 10 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..171e8d5
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,19 @@
+FROM oven/bun:1-alpine AS base
+
+WORKDIR /app
+
+FROM base AS build
+
+COPY package.json bun.lock ./
+
+RUN bun install --frozen-lockfile --production
+
+COPY *.ts tsconfig.json ./
+
+RUN bun build --production --target=bun --sourcemap=inline --outfile=index.js index.ts
+
+FROM base AS run
+
+COPY --from=build /app/index.js ./
+
+CMD ["bun", "run", "index.js"]
diff --git a/compose.yaml b/compose.yaml
new file mode 100644
index 0000000..ba68186
--- /dev/null
+++ b/compose.yaml
@@ -0,0 +1,6 @@
+services:
+ bot:
+ build: .
+ env_file: .env
+ restart: always
+ init: true
diff --git a/index.ts b/index.ts
index fc65e3f..afb43f8 100644
--- a/index.ts
+++ b/index.ts
@@ -107,15 +107,10 @@ client.on(Events.ThreadCreate, async (thread) => {
}
});
-try {
- await rest.put(Routes.applicationCommands(clientId), {
- body: slashCommands.map(command => command.slashCommand.toJSON()),
- });
+await rest.put(Routes.applicationCommands(clientId), {
+ body: slashCommands.map(command => command.slashCommand.toJSON()),
+});
- await client.login(token);
+await client.login(token);
- client.user?.setActivity(activity);
-} catch (error) {
- console.error("Discord bot failed to start", error);
- process.exit(1);
-}
+client.user?.setActivity(activity);