mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-16 08:54:58 +02:00
bootstrap volume to create db closes #6
This commit is contained in:
parent
54f5d159a5
commit
bfc81e52b0
3 changed files with 30 additions and 35 deletions
|
@ -4,10 +4,13 @@ import * as schema from "@server/db/schema";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs/promises";
|
import fs from "fs/promises";
|
||||||
import { APP_PATH } from "@server/lib/consts";
|
import { APP_PATH } from "@server/lib/consts";
|
||||||
|
import { existsSync, mkdirSync } from "fs";
|
||||||
|
|
||||||
export const location = path.join(APP_PATH, "db", "db.sqlite");
|
export const location = path.join(APP_PATH, "db", "db.sqlite");
|
||||||
export const exists = await checkFileExists(location);
|
export const exists = await checkFileExists(location);
|
||||||
|
|
||||||
|
bootstrapVolume();
|
||||||
|
|
||||||
const sqlite = new Database(location);
|
const sqlite = new Database(location);
|
||||||
export const db = drizzle(sqlite, { schema });
|
export const db = drizzle(sqlite, { schema });
|
||||||
|
|
||||||
|
@ -21,3 +24,29 @@ async function checkFileExists(filePath: string): Promise<boolean> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bootstrapVolume() {
|
||||||
|
const appPath = APP_PATH;
|
||||||
|
|
||||||
|
const dbDir = path.join(appPath, "db");
|
||||||
|
const logsDir = path.join(appPath, "logs");
|
||||||
|
|
||||||
|
// check if the db directory exists and create it if it doesn't
|
||||||
|
if (!existsSync(dbDir)) {
|
||||||
|
mkdirSync(dbDir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the logs directory exists and create it if it doesn't
|
||||||
|
if (!existsSync(logsDir)) {
|
||||||
|
mkdirSync(logsDir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS IS FOR TRAEFIK; NOT REALLY NEEDED, BUT JUST IN CASE
|
||||||
|
|
||||||
|
const traefikDir = path.join(appPath, "traefik");
|
||||||
|
|
||||||
|
// check if the traefik directory exists and create it if it doesn't
|
||||||
|
if (!existsSync(traefikDir)) {
|
||||||
|
mkdirSync(traefikDir, { recursive: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -33,8 +33,6 @@ export async function runMigrations() {
|
||||||
throw new Error("APP_VERSION is not set in the environment");
|
throw new Error("APP_VERSION is not set in the environment");
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrapVolume();
|
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
await executeScripts();
|
await executeScripts();
|
||||||
} else {
|
} else {
|
||||||
|
@ -109,35 +107,3 @@ async function executeScripts() {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bootstrapVolume() {
|
|
||||||
const appPath = APP_PATH;
|
|
||||||
|
|
||||||
const dbDir = path.join(appPath, "db");
|
|
||||||
const logsDir = path.join(appPath, "logs");
|
|
||||||
|
|
||||||
// check if the db directory exists and create it if it doesn't
|
|
||||||
if (!existsSync(dbDir)) {
|
|
||||||
mkdirSync(dbDir, { recursive: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if the logs directory exists and create it if it doesn't
|
|
||||||
if (!existsSync(logsDir)) {
|
|
||||||
mkdirSync(logsDir, { recursive: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
// THIS IS FOR TRAEFIK; NOT REALLY NEEDED, BUT JUST IN CASE
|
|
||||||
|
|
||||||
const traefikDir = path.join(appPath, "traefik");
|
|
||||||
const letsEncryptDir = path.join(traefikDir, "letsencrypt");
|
|
||||||
|
|
||||||
// check if the traefik directory exists and create it if it doesn't
|
|
||||||
if (!existsSync(traefikDir)) {
|
|
||||||
mkdirSync(traefikDir, { recursive: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if the letsencrypt directory exists and create it if it doesn't
|
|
||||||
if (!existsSync(letsEncryptDir)) {
|
|
||||||
mkdirSync(letsEncryptDir, { recursive: true });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -525,7 +525,7 @@ export default function CreateShareLinkForm({
|
||||||
</div>
|
</div>
|
||||||
<CollapsibleContent className="space-y-2">
|
<CollapsibleContent className="space-y-2">
|
||||||
{directLink && (
|
{directLink && (
|
||||||
<div className="space-y-1">
|
<div className="space-y-2">
|
||||||
<div className="mx-auto">
|
<div className="mx-auto">
|
||||||
<CopyTextBox
|
<CopyTextBox
|
||||||
text={directLink}
|
text={directLink}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue