diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..ef37f925 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +# use the official Bun image +# see all versions at https://hub.docker.com/r/oven/bun/tags +FROM oven/bun:debian as base +WORKDIR /usr/src/app + +RUN apt update +RUN apt install git + +RUN git clone https://github.com/rizrmd/prasi-bun --depth=1 +USER bun +RUN bun i +EXPOSE 4550/tcp +ENTRYPOINT [ "bun", "prod" ] \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index 0813dfed..deb58b49 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/deploy/captain-definition b/deploy/captain-definition deleted file mode 100644 index b0f979b6..00000000 --- a/deploy/captain-definition +++ /dev/null @@ -1,13 +0,0 @@ -{ - "schemaVersion": 2, - "dockerfileLines": [ - "FROM oven/bun", - "COPY package.json bun.lockb /temp/prod/", - "RUN cd /temp/prod && bun install --frozen-lockfile --production", - "RUN mkdir -p /temp/prod", - "COPY /temp/prod/node_modules node_modules", - "ENV PORT 80", - "EXPOSE 4550", - "CMD [ \"bun\", \"prod\" ]" - ] -} diff --git a/pkgs/core/index.ts b/pkgs/core/index.ts index 1f3bf7d4..06fceb0a 100644 --- a/pkgs/core/index.ts +++ b/pkgs/core/index.ts @@ -11,6 +11,7 @@ import { preparePrisma } from "./utils/prisma"; g.status = "init"; + await createLogger(); g.api = {}; g.mode = process.argv.includes("dev") ? "dev" : "prod"; @@ -22,17 +23,17 @@ if (g.mode === "dev") { } await preparePrisma(); -await ensureNotRunning(); +// await ensureNotRunning(); -if (g.db) { - g.db.$connect().catch((e: any) => { - g.log.error(`[DB ERROR]\n${e.message}`); - }); -} +// if (g.db) { +// g.db.$connect().catch((e: any) => { +// g.log.error(`[DB ERROR]\n${e.message}`); +// }); +// } -createServer(); -await parcelBuild(); -await generateAPIFrm(); -await prepareApiRoutes(); -await prepareAPITypes(); -g.status = "ready"; +// createServer(); +// await parcelBuild(); +// await generateAPIFrm(); +// await prepareApiRoutes(); +// await prepareAPITypes(); +// g.status = "ready"; diff --git a/pkgs/core/utils/prisma.ts b/pkgs/core/utils/prisma.ts index 0ea8a307..0550c35c 100644 --- a/pkgs/core/utils/prisma.ts +++ b/pkgs/core/utils/prisma.ts @@ -5,12 +5,14 @@ import { g } from "./global"; export const preparePrisma = async () => { if (await existsAsync(dir.path("app/db/.env"))) { - if (!(await existsAsync(dir.path("node_modules/.prisma")))) { + const hasPrisma = await existsAsync(dir.path("node_modules/.prisma")); + if (!hasPrisma) { await $({ cwd: dir.path(`app/db`) })`bun prisma generate`; } + const { PrismaClient } = await import("../../../app/db/db"); g.db = new PrismaClient(); } - + g.dburl = process.env.DATABASE_URL || ""; };