diff --git a/.dockerignore b/.dockerignore index cf70988..7b7127c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ **/node_modules +.env diff --git a/ingester.dockerfile b/ingester.dockerfile index a0b524a..ecbc5d6 100644 --- a/ingester.dockerfile +++ b/ingester.dockerfile @@ -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 diff --git a/ingesters/src/config/settings.ts b/ingesters/src/config/settings.ts index 96a5aec..9d04d6f 100644 --- a/ingesters/src/config/settings.ts +++ b/ingesters/src/config/settings.ts @@ -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; diff --git a/ingesters/src/utils/paths.ts b/ingesters/src/utils/paths.ts index 5ac591d..0d8212f 100644 --- a/ingesters/src/utils/paths.ts +++ b/ingesters/src/utils/paths.ts @@ -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); }