Skip to content

Commit dd732c8

Browse files
committed
fix: use OPENMAPX_ROOT_DIR for the admin data inventory paths
The data-workflows page in /admin/services/data showed every service as "Not built", "No OSM PBF found", "No GTFS feeds imported", "No MOTIS config" even though the data was sitting on disk and being read by the live containers. Cause: `admin-ops.ts` had its own DIY `findInfraDir()` that walked four levels up from `import.meta.url`. In the esbuild-bundled production build the dist file is at `/app/apps/api/dist/server.js`, so the walk landed on `/app` and joined `infra/docker` → `/app/infra/docker`, which doesn't exist in the container. The actual data is at `${OPENMAPX_HOST_DIR}/infra/docker/data`, bind-mounted at the same absolute path inside the container and pointed to by the existing `OPENMAPX_ROOT_DIR` env. Switch to `repoPaths()` from @openmapx/core (already used everywhere else for path resolution) which honours that env, and fall back to the relative walk only when the env isn't set and a workspace marker is reachable.
1 parent 74d0144 commit dd732c8

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

apps/api/src/services/admin-ops.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,28 @@ export interface HardlinkApplySummary {
3535
}
3636

3737
// Path resolution
38+
//
39+
// Order of preference (matches the rest of apps/api):
40+
// 1. `DOCKER_INFRA_DIR` — explicit override.
41+
// 2. `OPENMAPX_ROOT_DIR` (resolved by `repoPaths()`) — set by the rendered
42+
// compose to the host repo path that is bind-mounted at the same
43+
// absolute path inside the container, so `<root>/infra/docker/data`
44+
// always points at the real data dir.
45+
// 3. Walk up from this file's location — only useful in dev (`pnpm dev`),
46+
// because esbuild's bundled `apps/api/dist/server.js` collapses the
47+
// directory layout and a `../../../..` walk lands on `/app`.
3848

3949
function findInfraDir(): string {
4050
if (process.env.DOCKER_INFRA_DIR) return process.env.DOCKER_INFRA_DIR;
41-
// Compute from this file: apps/api/src/services/ → ../../../../infra/docker
42-
const thisFile = fileURLToPath(import.meta.url);
43-
return join(dirname(thisFile), "..", "..", "..", "..", "infra", "docker");
51+
try {
52+
return repoPaths().infraDir;
53+
} catch {
54+
// `findRepoRoot()` couldn't see a workspace marker (bundled prod build
55+
// without OPENMAPX_ROOT_DIR set, or running outside the repo tree).
56+
// Fall back to the relative-walk heuristic.
57+
const thisFile = fileURLToPath(import.meta.url);
58+
return join(dirname(thisFile), "..", "..", "..", "..", "infra", "docker");
59+
}
4460
}
4561

4662
export const INFRA_DIR = findInfraDir();

0 commit comments

Comments
 (0)