From 86f391e131f6bbecf6b6d3fe4e9cf45e9476b5a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Tri=C3=B1anes?= Date: Fri, 25 Oct 2024 10:05:11 +0200 Subject: [PATCH 1/3] Enable corepack --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bab9aba..d7e6e30 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "node": ">=20", "pnpm": ">=9" }, - "packageManager": "pnpm@9.6.0", "dependencies": { "@prisma/client": "^5.18.0", "@sapphire/discord.js-utilities": "^7.3.0", @@ -59,5 +58,6 @@ "eslint-config-prettier": "^9.1.0", "prettier": "3.2.4", "prisma": "^5.18.0" - } + }, + "packageManager": "pnpm@9.12.2+sha512.22721b3a11f81661ae1ec68ce1a7b879425a1ca5b991c975b074ac220b187ce56c708fe5db69f4c962c989452eee76c82877f4ee80f474cebd61ee13461b6228" } From bc7f2ffcfdd8254eedcbae4bf753f8d0d8af9826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Tri=C3=B1anes?= Date: Fri, 25 Oct 2024 10:05:11 +0200 Subject: [PATCH 2/3] Add nixpacks config --- nixpacks.toml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 nixpacks.toml diff --git a/nixpacks.toml b/nixpacks.toml new file mode 100644 index 0000000..79ca16c --- /dev/null +++ b/nixpacks.toml @@ -0,0 +1,5 @@ +[phases.build] +cmds = ["pnpm prisma generate", "..."] + +[start] +cmd = 'pnpm run start:migrate' From 9ebf8a69387b24dbf1e841a2a95e06adc4ac8970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Tri=C3=B1anes?= Date: Fri, 25 Oct 2024 10:46:35 +0200 Subject: [PATCH 3/3] Allow redis to use password auth --- .env.example | 9 ++++++--- src/index.ts | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 8ac0a57..115b92a 100644 --- a/.env.example +++ b/.env.example @@ -3,15 +3,18 @@ DISCORD_TOKEN= # Bot token from: https://discord.com/developers/ # Configuration DEFAULT_PREFIX= # Prefix used to run commands in Discord -DEVELOPMENT= # (true/false) Enables developer mode +DEVELOPMENT= # (true/false) Enables developer mode # Docker POSTGRES_USER=USERNAME POSTGRES_PASSWORD=PASSWORD POSTGRES_DB=DB -# Redis -REDIS_URL= # URL to redis database (if running everything within docker compose, use "redis") +# Redis (if running everything within docker compose, use "redis" for the host and leave the rest empty) +REDIS_HOST= # URL to redis database +REDIS_USER= # redis database user +REDIS_PASSWORD= # redis database password +REDIS_PORT= # redis database port # Database URL (designed for Postgres, but designed on Prisma) DATABASE_URL= # "postgresql://USERNAME:PASSWORD@postgres:5432/DB?schema=ara&sslmode=prefer" diff --git a/src/index.ts b/src/index.ts index af16d15..4b3e00d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,6 +27,10 @@ import '@sapphire/plugin-logger/register'; import { PrismaClient } from '@prisma/client'; import { Redis } from 'ioredis'; +const REDIS_PORT = process.env.REDIS_PORT + ? parseInt(process.env.REDIS_PORT) + : undefined; + // Setting up the Sapphire client const client = new SapphireClient({ defaultPrefix: process.env.DEFAULT_PREFIX, @@ -49,7 +53,10 @@ const client = new SapphireClient({ tasks: { bull: { connection: { - host: process.env.REDIS_URL, + host: process.env.REDIS_HOST, + username: process.env.REDIS_USER, + password: process.env.REDIS_PASSWORD, + port: REDIS_PORT, }, }, }, @@ -62,9 +69,12 @@ const main = async () => { client.logger.info('Logging in'); // Create databases - container.database = await new PrismaClient(); + container.database = new PrismaClient(); container.redis = new Redis({ - host: process.env.REDIS_URL, + host: process.env.REDIS_HOST, + username: process.env.REDIS_USER, + password: process.env.REDIS_PASSWORD, + port: REDIS_PORT, db: 1, });