fix prisma

This commit is contained in:
Rizky 2024-01-21 12:20:12 +07:00
parent 1c710ee34d
commit 7458aad85a
2 changed files with 10 additions and 28 deletions

View File

@ -1,27 +1,10 @@
# use the official ubuntu image # use the official ubuntu image
FROM ubuntu:latest as base FROM oven/bun:1.0.18-debian as base
WORKDIR /usr/src WORKDIR /usr/src/prasi
RUN echo $DATABASE_URL COPY . .
RUN bun install
RUN bun run build
# COPY . . EXPOSE 3000
CMD [ "bun run prod" ]
# 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" ]

View File

@ -5,10 +5,9 @@ import { g } from "./global";
export const preparePrisma = async () => { export const preparePrisma = async () => {
if (await existsAsync(dir.path("app/db/.env"))) { if (await existsAsync(dir.path("app/db/.env"))) {
const hasPrisma = await existsAsync(dir.path("node_modules/.prisma")); g.log.info("Prisma: db pull & generate");
if (!hasPrisma) { await $({ cwd: dir.path(`app/db`) })`bun prisma db pull`;
await $({ cwd: dir.path(`app/db`) })`bun prisma generate`; await $({ cwd: dir.path(`app/db`) })`bun prisma generate`;
}
const { PrismaClient } = await import("../../../app/db/db"); const { PrismaClient } = await import("../../../app/db/db");
g.db = new PrismaClient(); g.db = new PrismaClient();