Initial commit: page-manager Next.js app with Coolify deploy support

Replace Vercel-specific infra (Cron, Blob) with self-hosted equivalents
for deployment to Coolify: in-container cron scheduler
(scripts/cron-runner.mjs) and disk-based upload storage served via
/api/uploads/[...path]. Add Dockerfile, .dockerignore, and /api/health
for container health checks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
chaloemphong
2026-11-22 11:52:17 +07:00
commit 9d32552457
155 changed files with 22174 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
// In-container replacement for Vercel Cron (see vercel.json's old schedule).
// Runs alongside `node server.js` in the Docker image — see Dockerfile.
import "dotenv/config";
const PORT = process.env.PORT || 3000;
const BASE = `http://127.0.0.1:${PORT}`;
const SECRET = process.env.CRON_SECRET;
if (!SECRET) {
console.error("[cron] CRON_SECRET not set — scheduler exiting");
process.exit(1);
}
// Schedules match the original vercel.json (UTC — containers default to UTC).
const JOBS = [
{ path: "/api/cron/insights-snapshot", match: (d) => d.getUTCHours() === 2 && d.getUTCMinutes() === 0 },
{ path: "/api/cron/reconcile-scheduled", match: (d) => d.getUTCHours() === 3 && d.getUTCMinutes() === 0 },
{ path: "/api/cron/token-health", match: (d) => d.getUTCHours() === 3 && d.getUTCMinutes() === 30 },
{ path: "/api/cron/ig-publisher", match: (d) => d.getUTCMinutes() % 10 === 0 },
];
async function run(jobPath) {
try {
const res = await fetch(`${BASE}${jobPath}`, { headers: { authorization: `Bearer ${SECRET}` } });
console.log(`[cron] ${jobPath} -> ${res.status}`);
} catch (e) {
console.error(`[cron] ${jobPath} failed:`, e?.message ?? e);
}
}
setInterval(() => {
const now = new Date();
for (const job of JOBS) if (job.match(now)) run(job.path);
}, 60_000);
console.log("[cron] scheduler started");