fix docker image
This commit is contained in:
parent
f3e13d9fa8
commit
fae839ba89
|
|
@ -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" ]
|
||||||
|
|
@ -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\" ]"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -11,6 +11,7 @@ import { preparePrisma } from "./utils/prisma";
|
||||||
|
|
||||||
g.status = "init";
|
g.status = "init";
|
||||||
|
|
||||||
|
|
||||||
await createLogger();
|
await createLogger();
|
||||||
g.api = {};
|
g.api = {};
|
||||||
g.mode = process.argv.includes("dev") ? "dev" : "prod";
|
g.mode = process.argv.includes("dev") ? "dev" : "prod";
|
||||||
|
|
@ -22,17 +23,17 @@ if (g.mode === "dev") {
|
||||||
}
|
}
|
||||||
|
|
||||||
await preparePrisma();
|
await preparePrisma();
|
||||||
await ensureNotRunning();
|
// await ensureNotRunning();
|
||||||
|
|
||||||
if (g.db) {
|
// if (g.db) {
|
||||||
g.db.$connect().catch((e: any) => {
|
// g.db.$connect().catch((e: any) => {
|
||||||
g.log.error(`[DB ERROR]\n${e.message}`);
|
// g.log.error(`[DB ERROR]\n${e.message}`);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
createServer();
|
// createServer();
|
||||||
await parcelBuild();
|
// await parcelBuild();
|
||||||
await generateAPIFrm();
|
// await generateAPIFrm();
|
||||||
await prepareApiRoutes();
|
// await prepareApiRoutes();
|
||||||
await prepareAPITypes();
|
// await prepareAPITypes();
|
||||||
g.status = "ready";
|
// g.status = "ready";
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,11 @@ 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"))) {
|
||||||
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`;
|
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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue