chore(ops): harden deployment and runtime setup
This commit is contained in:
parent
1d7e7c41c9
commit
c35bd5877e
30 changed files with 534 additions and 61 deletions
39
lib/runtime/config.ts
Normal file
39
lib/runtime/config.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { existsSync } from "fs";
|
||||
import { access, mkdir, writeFile, rm } from "fs/promises";
|
||||
import path from "path";
|
||||
import { appVersion } from "./version";
|
||||
|
||||
export const dataDirectory = path.join(process.cwd(), "data");
|
||||
export const uploadDirectory = path.join(process.cwd(), "public", "uploads", "images");
|
||||
|
||||
export function adminConfigurationStatus() {
|
||||
return process.env.ADMIN_EMAIL && process.env.ADMIN_PASSWORD && process.env.ADMIN_SESSION_SECRET ? "configured" : "missing";
|
||||
}
|
||||
|
||||
export function isDockerEnvironment() {
|
||||
return process.env.DOCKER_ENV === "true" || process.env.CONTAINER === "true" || existsSync("/.dockerenv");
|
||||
}
|
||||
|
||||
export async function ensureRuntimeDirectories() {
|
||||
await mkdir(dataDirectory, { recursive: true });
|
||||
await mkdir(uploadDirectory, { recursive: true });
|
||||
}
|
||||
|
||||
export async function checkStorage() {
|
||||
await ensureRuntimeDirectories();
|
||||
const probe = path.join(dataDirectory, `.storage-check-${Date.now()}`);
|
||||
await writeFile(probe, "ok", "utf8");
|
||||
await rm(probe, { force: true });
|
||||
await access(uploadDirectory);
|
||||
return "ok";
|
||||
}
|
||||
|
||||
export function olympusStatus() {
|
||||
return process.env.OLYMPUS_INTAKE_API_URL && process.env.OLYMPUS_INTAKE_API_TOKEN ? "configured" : "not_configured";
|
||||
}
|
||||
|
||||
export function smtpStatus() {
|
||||
return "prepared";
|
||||
}
|
||||
|
||||
export { appVersion };
|
||||
Loading…
Add table
Add a link
Reference in a new issue