diff --git a/packages/compute-worker/src/infrastructure/platform.ts b/packages/compute-worker/src/infrastructure/platform.ts index 9f029e4..3752a17 100644 --- a/packages/compute-worker/src/infrastructure/platform.ts +++ b/packages/compute-worker/src/infrastructure/platform.ts @@ -14,8 +14,23 @@ function findMonorepoRoot(startDir: string): string | null { } function resolveDocstoreDir(): string { + // 1. Try to find the monorepo root (works in local development) const repoRoot = findMonorepoRoot(process.cwd()); if (repoRoot) return path.join(repoRoot, 'docstore'); + + // 2. In a containerized environment, the parent bootstrap process runs in /app + // and the child process inherits process.env.PWD = '/app'. + if (process.env.PWD) { + const pwdDocstore = path.join(process.env.PWD, 'docstore'); + if (fs.existsSync(pwdDocstore)) return pwdDocstore; + } + + // 3. Fallback to the standard container app docstore path if it exists + if (fs.existsSync('/app/docstore')) { + return '/app/docstore'; + } + + // 4. Fallback to the process cwd docstore return path.join(process.cwd(), 'docstore'); }