diff --git a/Dockerfile b/Dockerfile index b36f7c7..6bc3707 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,10 @@ -FROM node - +FROM node:lts-alpine3.18 WORKDIR /app - COPY . . - -RUN npm i && \ - npm run generate && \ - rm -rf node_modules && \ - npm ci --omit=dev +RUN npm i +RUN npm run generate +RUN npx tsx ./src/db/postgres/migrate.ts +RUN rm -rf node_modules +RUN npm ci --omit=dev ENTRYPOINT [ "npx", "tsx", "./src/main.ts" ] diff --git a/src/db/postgres/index.ts b/src/db/postgres/index.ts index 8cb7ec8..c470961 100644 --- a/src/db/postgres/index.ts +++ b/src/db/postgres/index.ts @@ -13,6 +13,7 @@ export type DB = typeof db export async function startMigration() { console.log('Running migration...') - await migrate(db, { migrationsFolder: 'drizzle' }) + await migrate(db, { migrationsFolder: './drizzle' }) console.log('Migrations is done') -} \ No newline at end of file +} + diff --git a/src/db/postgres/migrate.ts b/src/db/postgres/migrate.ts new file mode 100644 index 0000000..ff4aec8 --- /dev/null +++ b/src/db/postgres/migrate.ts @@ -0,0 +1,6 @@ +import { migrate } from 'drizzle-orm/libsql/migrator' +import { db } from '.' + +console.log('Running migration...') +await migrate(db, { migrationsFolder: './drizzle' }) +console.log('Migrations is done') diff --git a/src/main.ts b/src/main.ts index 9b7dbd2..fdf0f7c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,11 +3,9 @@ import { message } from 'telegraf/filters' import Bot from './Bot.js' import config from './config/config.js' import { startCron } from './cron.js' -import { startMigration } from './db/postgres/index.js' import { saldoHandler } from './handlers/saldoHandler.js' import { checkUserMiddleware } from './middlewares/user.middleware.js' -startMigration() startCron() const app = new Bot(config.botToken)