Skip to content

Commit

Permalink
stats-updater: Fix Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Aug 18, 2024
1 parent 4f1d1c6 commit ae76c11
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 24 deletions.
2 changes: 1 addition & 1 deletion apps/stats-updater/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
19 changes: 0 additions & 19 deletions apps/stats-updater/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions apps/stats-updater/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion apps/stats-updater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ae76c11

Please sign in to comment.