From ae76c11f4d33a1889b020d7fe0e26aeb5c2e4b5f Mon Sep 17 00:00:00 2001 From: Bruno Perel Date: Sun, 18 Aug 2024 16:57:02 +0200 Subject: [PATCH] stats-updater: Fix Dockerfile --- apps/stats-updater/Dockerfile | 2 +- apps/stats-updater/db.ts | 19 ------------------- apps/stats-updater/index.ts | 3 --- apps/stats-updater/package.json | 2 +- 4 files changed, 2 insertions(+), 24 deletions(-) diff --git a/apps/stats-updater/Dockerfile b/apps/stats-updater/Dockerfile index d2b35dd67..32bbe0126 100644 --- a/apps/stats-updater/Dockerfile +++ b/apps/stats-updater/Dockerfile @@ -8,7 +8,7 @@ RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.bashrc" SHELL="$(whic COPY apps/stats-updater/bundle.mjs /app/ -COPY packages/prisma-schemas/client_dm/libquery_engine-debian-openssl-1.1.x.so.node /tmp/prisma-engines/ +COPY packages/prisma-schemas/client_dm_stats/ / EXPOSE 3000 ENTRYPOINT ["bun", "bundle.mjs"] \ No newline at end of file diff --git a/apps/stats-updater/db.ts b/apps/stats-updater/db.ts index c922a8103..da25c2a70 100644 --- a/apps/stats-updater/db.ts +++ b/apps/stats-updater/db.ts @@ -63,25 +63,6 @@ export const runMigrations = async () => { } }; -export const generatePrismaClient = async () => { - const { stdout, stderr } = spawnSync( - "pnpm", - ["-F", "~prisma-schemas", "prisma-generate"], - { - encoding: "utf8", - env: { - ...process.env, - SCHEMA: "dm_stats", - }, - }, - ); - - console.log(stdout); - if (stderr) { - throw new Error(stderr); - } -}; - export const runQuery = async (sql: string) => { console.log(new Date().toISOString()); console.debug(sql); diff --git a/apps/stats-updater/index.ts b/apps/stats-updater/index.ts index f5cbbf840..32efcffc5 100644 --- a/apps/stats-updater/index.ts +++ b/apps/stats-updater/index.ts @@ -36,16 +36,13 @@ db.connect().then(async () => { await import("~prisma-schemas/schemas/dm_stats/client") ).prismaClient; - process.env.DATABASE_URL_DM = process.env.DATABASE_URL_DM; const prismaDm = (await import("~prisma-schemas/schemas/dm/client")) .prismaClient; - process.env.DATABASE_URL_COA = process.env.DATABASE_URL_COA; const prismaCoa = (await import("~prisma-schemas/schemas/coa/client")) .prismaClient; await db.runMigrations(); - await db.generatePrismaClient(); const authorUsers = await prismaDm.authorUser.findMany({ where: { diff --git a/apps/stats-updater/package.json b/apps/stats-updater/package.json index b61ed08cf..0ecf0ea00 100644 --- a/apps/stats-updater/package.json +++ b/apps/stats-updater/package.json @@ -4,7 +4,7 @@ "description": "Daily stats calculation for DucksManager", "main": "index.ts", "scripts": { - "build": "bun build --target bun --sourcemap index.ts --outfile bundle.mjs" + "build": "bun build --target bun --sourcemap index.ts --outfile bundle.mjs && SCHEMA='dm_stats' pnpm -r '~prisma-clients' prisma-generate" }, "dependencies": { "dotenv": "^16.4.5",