Compare commits
2 commits
main
...
v0.27.0-be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca2a2cb74f | ||
|
|
436a63a4b4 |
6 changed files with 51 additions and 12 deletions
|
|
@ -100,7 +100,6 @@ ENV PORT=4096
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY --from=builder /app/package.json ./
|
COPY --from=builder /app/package.json ./
|
||||||
RUN bun install --production --frozen-lockfile && rm -rf $HOME/.bun/install/cache
|
|
||||||
|
|
||||||
COPY --from=deps /deps/restic /usr/local/bin/restic
|
COPY --from=deps /deps/restic /usr/local/bin/restic
|
||||||
COPY --from=deps /deps/rclone /usr/local/bin/rclone
|
COPY --from=deps /deps/rclone /usr/local/bin/rclone
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,23 @@
|
||||||
import * as schema from "./server/db/schema";
|
|
||||||
import { setSchema, runDbMigrations } from "./server/db/db";
|
|
||||||
import { startup } from "./server/modules/lifecycle/startup";
|
|
||||||
import { logger } from "./server/utils/logger";
|
import { logger } from "./server/utils/logger";
|
||||||
import { shutdown } from "./server/modules/lifecycle/shutdown";
|
import { shutdown } from "./server/modules/lifecycle/shutdown";
|
||||||
import { runCLI } from "./server/cli";
|
import { runCLI } from "./server/cli";
|
||||||
import { runMigrations } from "./server/modules/lifecycle/migrations";
|
|
||||||
import { createStartHandler, defaultStreamHandler, defineHandlerCallback } from "@tanstack/react-start/server";
|
import { createStartHandler, defaultStreamHandler, defineHandlerCallback } from "@tanstack/react-start/server";
|
||||||
import { createServerEntry } from "@tanstack/react-start/server-entry";
|
import { createServerEntry } from "@tanstack/react-start/server-entry";
|
||||||
|
import { initAuth } from "~/server/lib/auth";
|
||||||
setSchema(schema);
|
import { setSchema } from "./server/db/db";
|
||||||
|
import * as schema from "./server/db/schema";
|
||||||
|
import { toMessage } from "./server/utils/errors";
|
||||||
|
|
||||||
const cliRun = await runCLI(Bun.argv);
|
const cliRun = await runCLI(Bun.argv);
|
||||||
if (cliRun) {
|
if (cliRun) {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
runDbMigrations();
|
setSchema(schema);
|
||||||
|
await initAuth().catch((err) => {
|
||||||
await runMigrations();
|
logger.error(`Error initializing auth: ${toMessage(err)}`);
|
||||||
await startup();
|
throw err;
|
||||||
|
});
|
||||||
|
|
||||||
const customHandler = defineHandlerCallback((ctx) => {
|
const customHandler = defineHandlerCallback((ctx) => {
|
||||||
return defaultStreamHandler(ctx);
|
return defaultStreamHandler(ctx);
|
||||||
|
|
|
||||||
26
app/server/modules/lifecycle/bootstrap.ts
Normal file
26
app/server/modules/lifecycle/bootstrap.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
import * as schema from "../../db/schema";
|
||||||
|
import { runDbMigrations, setSchema } from "../../db/db";
|
||||||
|
import { runMigrations } from "./migrations";
|
||||||
|
import { startup } from "./startup";
|
||||||
|
|
||||||
|
let bootstrapPromise: Promise<void> | undefined;
|
||||||
|
|
||||||
|
const runBootstrap = async () => {
|
||||||
|
setSchema(schema);
|
||||||
|
runDbMigrations();
|
||||||
|
await runMigrations();
|
||||||
|
await startup();
|
||||||
|
};
|
||||||
|
|
||||||
|
export const bootstrapApplication = async () => {
|
||||||
|
if (!bootstrapPromise) {
|
||||||
|
bootstrapPromise = runBootstrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await bootstrapPromise;
|
||||||
|
} catch (err) {
|
||||||
|
bootstrapPromise = undefined;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
11
app/server/plugins/bootstrap.ts
Normal file
11
app/server/plugins/bootstrap.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { definePlugin } from "nitro";
|
||||||
|
import { bootstrapApplication } from "../modules/lifecycle/bootstrap";
|
||||||
|
import { logger } from "../utils/logger";
|
||||||
|
import { toMessage } from "../utils/errors";
|
||||||
|
|
||||||
|
export default definePlugin(() => {
|
||||||
|
void bootstrapApplication().catch((err) => {
|
||||||
|
logger.error(`Bootstrap failed: ${toMessage(err)}`);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -43,6 +43,7 @@ services:
|
||||||
- APP_SECRET=94bad4678ce84a60b9789bd2114a6bf780aeb38df426f7352c941c66e25d5c2b
|
- APP_SECRET=94bad4678ce84a60b9789bd2114a6bf780aeb38df426f7352c941c66e25d5c2b
|
||||||
- BASE_URL=http://localhost:4096
|
- BASE_URL=http://localhost:4096
|
||||||
- PORT=4096
|
- PORT=4096
|
||||||
|
- LOG_LEVEL=debug
|
||||||
volumes:
|
volumes:
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
- /var/lib/zerobyte:/var/lib/zerobyte
|
- /var/lib/zerobyte:/var/lib/zerobyte
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,10 @@ export default defineConfig({
|
||||||
routesDirectory: "routes",
|
routesDirectory: "routes",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
nitro({ preset: "bun" }),
|
nitro({
|
||||||
|
preset: "bun",
|
||||||
|
plugins: ["./app/server/plugins/bootstrap.ts"],
|
||||||
|
}),
|
||||||
viteReact({
|
viteReact({
|
||||||
babel: {
|
babel: {
|
||||||
plugins: ["babel-plugin-react-compiler"],
|
plugins: ["babel-plugin-react-compiler"],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue