Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/node_modules
.env
2 changes: 0 additions & 2 deletions ingester.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ WORKDIR /app
# Copy ingester files
COPY ingesters ./ingesters

# Copy .env file for configuration
COPY .env ./.env

# Copy ingester files generated from python
COPY python/src/scripts/summarizer/generated ./python/src/scripts/summarizer/generated
Expand Down
9 changes: 8 additions & 1 deletion ingesters/src/config/settings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { type VectorStoreConfig } from '../types';
import dotenv from 'dotenv';
import { getRepoPath } from '../utils/paths';
import { existsSync } from 'fs';

dotenv.config({ path: getRepoPath('.env') });
// Load .env from repo root if present; otherwise rely on runtime env vars.
const envPath = getRepoPath('.env');
if (existsSync(envPath)) {
dotenv.config({ path: envPath });
} else {
dotenv.config();
}

// API Keys from environment variables only
export const getOpenaiApiKey = () => process.env.OPENAI_API_KEY;
Expand Down
12 changes: 5 additions & 7 deletions ingesters/src/utils/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ import path from 'path';
import { existsSync } from 'fs';

/**
* Find the repository root by looking for .git directory
* Find the repository root by looking for package.json and going up the directory tree
*/
function findRepoRoot(): string {
let currentDir = import.meta.dir; // Bun's way to get current directory

// Walk up the directory tree looking for .env
// Walk up the directory tree looking for package.json
while (currentDir !== '/') {
if (
existsSync(path.join(currentDir, '.env')) ||
existsSync(path.join(currentDir, '.git'))
) {
return currentDir;
if (existsSync(path.join(currentDir, 'package.json'))) {
// Go one level up from the package.json location
return path.dirname(currentDir);
}
currentDir = path.dirname(currentDir);
}
Expand Down