fix: 收紧发布环境与任务文件边界
This commit is contained in:
1 parent
2fe108d66a
commit
3af5611da5
5 files changed
+103
-16
No files matched your search
@@ -16,6 +16,7 @@ import {
|
||||
import path from "node:path";
|
||||
import { spawn, spawnSync } from "node:child_process";
|
||||
import { checkPackage } from "../scripts/deploy/check-package.mjs";
|
||||
import { assertReleaseEnvironment } from "./release-environment.mjs";
|
||||
|
||||
const root = process.env.DEPLOY_ROOT;
|
||||
if (!root || !path.isAbsolute(root)) throw new Error("DEPLOY_ROOT must be absolute");
|
||||
@@ -28,20 +29,7 @@ if (!postgresContainer || !/^[a-zA-Z0-9_.-]+$/.test(postgresContainer)) {
|
||||
throw new Error("POSTGRES_CONTAINER is required for the database backup");
|
||||
}
|
||||
if (Number(process.versions.node.split(".")[0]) !== 24) throw new Error("Node.js 24 is required");
|
||||
if (
|
||||
process.env.NODE_ENV !== "production" ||
|
||||
!process.env.DATABASE_URL ||
|
||||
!process.env.SESSION_SECRET ||
|
||||
process.env.SESSION_SECRET.length < 32 ||
|
||||
!process.env.DEFAULT_BRAND_ID ||
|
||||
!process.env.LOCAL_MEDIA_ROOT
|
||||
) {
|
||||
throw new Error("Production environment is missing required values");
|
||||
}
|
||||
if (!path.isAbsolute(process.env.LOCAL_MEDIA_ROOT))
|
||||
throw new Error("LOCAL_MEDIA_ROOT must be absolute");
|
||||
if (process.env.API_PREFIX) throw new Error("API_PREFIX must be empty when Traefik strips /api");
|
||||
const databaseUrl = new URL(process.env.DATABASE_URL);
|
||||
const databaseUrl = assertReleaseEnvironment(process.env);
|
||||
const privateDatabaseHost = /^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[0-1])\.)/.test(
|
||||
databaseUrl.hostname,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user