From 7458aad85aaa4dc601c7504326234ad64c24ec8c Mon Sep 17 00:00:00 2001 From: Rizky Date: Sun, 21 Jan 2024 12:20:12 +0700 Subject: [PATCH] fix prisma --- Dockerfile | 31 +++++++------------------------ pkgs/core/utils/prisma.ts | 7 +++---- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/Dockerfile b/Dockerfile index 675d78b7..4e077f91 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,10 @@ # use the official ubuntu image -FROM ubuntu:latest as base -WORKDIR /usr/src +FROM oven/bun:1.0.18-debian as base +WORKDIR /usr/src/prasi -RUN echo $DATABASE_URL +COPY . . +RUN bun install +RUN bun run build -# COPY . . - -# RUN apt-get update -# RUN apt-get install -y curl unzip zip bash gnupg - -# RUN curl -sL https://deb.nodesource.com/setup_20.x | bash - -# RUN apt-get -y install nodejs -# RUN npm install -g pm2 -# RUN npm install -g node-gyp -# RUN npm install -g node-gyp-build-optional-packages - -# RUN curl -fsSL https://bun.sh/install | bash -s "bun-v1.0.18" -# RUN ln -s $HOME/.bun/bin/bun /usr/local/bin/bun - -# RUN bun repl -e 'console.log(process.env["DATABASE_URL"]);' -# RUN bun install -# RUN bun run build -# RUN cd app/db && bun prisma db pull && bun prisma generate - -# EXPOSE 3000 -# CMD [ "pm2-runtime", "bun run prod" ] +EXPOSE 3000 +CMD [ "bun run prod" ] diff --git a/pkgs/core/utils/prisma.ts b/pkgs/core/utils/prisma.ts index 0550c35c..f0d7e2b6 100644 --- a/pkgs/core/utils/prisma.ts +++ b/pkgs/core/utils/prisma.ts @@ -5,10 +5,9 @@ import { g } from "./global"; export const preparePrisma = async () => { if (await existsAsync(dir.path("app/db/.env"))) { - const hasPrisma = await existsAsync(dir.path("node_modules/.prisma")); - if (!hasPrisma) { - await $({ cwd: dir.path(`app/db`) })`bun prisma generate`; - } + g.log.info("Prisma: db pull & generate"); + await $({ cwd: dir.path(`app/db`) })`bun prisma db pull`; + await $({ cwd: dir.path(`app/db`) })`bun prisma generate`; const { PrismaClient } = await import("../../../app/db/db"); g.db = new PrismaClient();