Skip to content

Commit f0ff801

Browse files
authored
fix: remove reliance on .env in docker image (#79)
1 parent f7aea2f commit f0ff801

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
**/node_modules
2+
.env

ingester.dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ WORKDIR /app
1414
# Copy ingester files
1515
COPY ingesters ./ingesters
1616

17-
# Copy .env file for configuration
18-
COPY .env ./.env
1917

2018
# Copy ingester files generated from python
2119
COPY python/src/scripts/summarizer/generated ./python/src/scripts/summarizer/generated

ingesters/src/config/settings.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import { type VectorStoreConfig } from '../types';
22
import dotenv from 'dotenv';
33
import { getRepoPath } from '../utils/paths';
4+
import { existsSync } from 'fs';
45

5-
dotenv.config({ path: getRepoPath('.env') });
6+
// Load .env from repo root if present; otherwise rely on runtime env vars.
7+
const envPath = getRepoPath('.env');
8+
if (existsSync(envPath)) {
9+
dotenv.config({ path: envPath });
10+
} else {
11+
dotenv.config();
12+
}
613

714
// API Keys from environment variables only
815
export const getOpenaiApiKey = () => process.env.OPENAI_API_KEY;

ingesters/src/utils/paths.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ import path from 'path';
22
import { existsSync } from 'fs';
33

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

10-
// Walk up the directory tree looking for .env
10+
// Walk up the directory tree looking for package.json
1111
while (currentDir !== '/') {
12-
if (
13-
existsSync(path.join(currentDir, '.env')) ||
14-
existsSync(path.join(currentDir, '.git'))
15-
) {
16-
return currentDir;
12+
if (existsSync(path.join(currentDir, 'package.json'))) {
13+
// Go one level up from the package.json location
14+
return path.dirname(currentDir);
1715
}
1816
currentDir = path.dirname(currentDir);
1917
}

0 commit comments

Comments
 (0)