feat(docker): healthcheck
This commit is contained in:
@@ -10,6 +10,11 @@ services:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- lbf-network
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
@@ -25,8 +30,10 @@ services:
|
||||
dockerfile: apps/discord-bot/Dockerfile
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_started
|
||||
networks:
|
||||
- lbf-network
|
||||
environment:
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
||||
import { env } from "~/env";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { dirname, join } from "node:path";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
export async function runMigrations() {
|
||||
console.log("Connecting to database...");
|
||||
const db = drizzle(env.DATABASE_URL);
|
||||
|
||||
await migrate(db, { migrationsFolder: "./drizzle" });
|
||||
const migrationsFolder = join(__dirname, "..", "drizzle");
|
||||
console.log(`Running migrations from: ${migrationsFolder}`);
|
||||
|
||||
await migrate(db, { migrationsFolder });
|
||||
|
||||
console.log("✅ Database migrations completed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user