make BOT/SHARED runtime paths env-configurable for containerized deploys

This commit is contained in:
deploy-migration
2026-07-02 13:06:03 +00:00
parent 3e0cdbc46f
commit 86b500cc77
+9 -9
View File
@@ -165,13 +165,13 @@ const log = {
debug: (...args) => isDev && console.log('[DEBUG]', ...args)
};
const REPO_ROOT = path.join(__dirname, '..');
const REPO_ROOT = process.env.BOT_REPO_ROOT || path.join(__dirname, '..');
const SQUADRON_RECAP_CACHE_DIR = path.join(STORAGE_ROOT, 'RECAPS', 'squadrons');
const PLAYER_RECAP_CACHE_DIR = path.join(STORAGE_ROOT, 'RECAPS', 'players');
const RECAP_TTL_MS = 24 * 60 * 60 * 1000; // in-progress season TTL
const RECAP_RENDER_TIMEOUT_MS = 30_000;
const PYTHON_BIN = path.join(REPO_ROOT, '..', 'SHARED', '.venv', 'bin', 'python');
const RECAP_SCRIPT = path.join(REPO_ROOT, 'BOT', 'render_recap.py');
const PYTHON_BIN = process.env.PYTHON_BIN || path.join(REPO_ROOT, '..', 'SHARED', '.venv', 'bin', 'python');
const RECAP_SCRIPT = process.env.RECAP_SCRIPT || path.join(REPO_ROOT, 'BOT', 'render_recap.py');
function resolveReplaySessionDir(sessionId) {
const sid = String(sessionId).toLowerCase();
@@ -1927,10 +1927,10 @@ app.get('/api/match/:sessionId/video', async (req, res) => {
_videoRenderCount++;
try {
await new Promise((resolve, reject) => {
const pythonBin = path.join(__dirname, '..', '..', 'SHARED', '.venv', 'bin', 'python');
const pythonBin = PYTHON_BIN;
execFile(pythonBin, ['-m', 'BOT.render_replay', replayPath, videoPath], {
timeout: 120000,
cwd: path.join(__dirname, '..')
cwd: REPO_ROOT
}, (error, stdout, stderr) => {
if (error) {
log.error('[Video] Generation stderr:', stderr);
@@ -1990,10 +1990,10 @@ app.get('/api/match/:sessionId/replay-canvas', async (req, res) => {
_canvasRenderCount++;
try {
await new Promise((resolve, reject) => {
const pythonBin = path.join(__dirname, '..', '..', 'SHARED', '.venv', 'bin', 'python');
const pythonBin = PYTHON_BIN;
execFile(pythonBin, ['-m', 'BOT.render_replay', replayPath, jsonPath], {
timeout: 30000,
cwd: path.join(__dirname, '..')
cwd: REPO_ROOT
}, (error, stdout, stderr) => {
if (error) {
log.error('[ReplayCanvas] Generation stderr:', stderr);
@@ -2026,7 +2026,7 @@ app.get('/api/icons/type/:name', (req, res) => {
if (!name || !/^[a-zA-Z0-9_\-]+$/.test(name)) {
return res.status(400).json({ error: 'Invalid icon name' });
}
const iconsBase = path.join(__dirname, '..', '..', 'SHARED', 'ICONS');
const iconsBase = process.env.SHARED_ICONS_DIR || path.join(REPO_ROOT, '..', 'SHARED', 'ICONS');
// Check: ICONS/ → FALLBACKS/ → MINIS/
const candidates = [
path.join(iconsBase, name + '.png'),
@@ -2053,7 +2053,7 @@ app.get('/api/match/minimap/:level', (req, res) => {
if (!level || !/^[a-zA-Z0-9_]+$/.test(level)) {
return res.status(400).json({ error: 'Invalid level name' });
}
const minimapsDir = path.join(__dirname, '..', '..', 'SHARED', 'MAPS', 'MINIMAPS');
const minimapsDir = process.env.SHARED_MINIMAPS_DIR || path.join(REPO_ROOT, '..', 'SHARED', 'MAPS', 'MINIMAPS');
const names = req.query.type === 'full'
? [level + '.png', level + '_map.png']
: [level + '_tankmap.png', level + '.png', level + '_map.png'];