Skip to content

Commit 67b5669

Browse files
env variable validation
1 parent a2928f8 commit 67b5669

5 files changed

Lines changed: 9 additions & 17 deletions

File tree

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ RUN bun install --frozen-lockfile
1212

1313
ADD ./ /app/
1414

15-
ENV OPENAI_API_KEY=${OPENAI_API_KEY}
15+
ARG OPENAI_API_KEY
16+
ENV OPENAI_API_KEY=$OPENAI_API_KEY
1617

1718
RUN bun run build
1819

1920
RUN bun run download-content
20-
RUN bun run init-vector-store
21+
RUN OPENAI_API_KEY=$OPENAI_API_KEY bun run init-vector-store
2122

2223
EXPOSE 1234
2324

24-
CMD ["bun", "run", "dist/index.js"]
25+
CMD ["bun", "run", "start"]

bun.lock

Lines changed: 1 addition & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"@modelcontextprotocol/sdk": "^1.17.4",
3030
"ai": "^5.0.23",
3131
"dedent": "^1.6.0",
32-
"dotenv": "^17.2.1",
3332
"front-matter": "^4.0.2",
3433
"giget": "^2.0.0",
3534
"mcp-framework": "^0.2.15",

scripts/init-vector-store.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { vectorStore, VectorStoreMetadata } from "../src/lib/vector-store";
33
import { getContent } from "../src/lib/utils/content";
44
import { embedMany } from "ai";
55
import { openai } from "@ai-sdk/openai";
6-
import { librariesWithFeatures } from "../src/lib/utils/process-libraries";
6+
7+
if (!process.env.OPENAI_API_KEY) {
8+
throw new Error("OPENAI_API_KEY is not set");
9+
}
710

811
const BATCH_SIZE = process.env.BATCH_SIZE
912
? parseInt(process.env.BATCH_SIZE)

src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { MCPServer } from "mcp-framework";
2-
import { config } from "dotenv";
3-
import path from "path";
42
import { initLibrariesWithFeatures } from "./lib/utils/process-libraries.js";
53
import { vectorStore } from "./lib/vector-store.js";
64

7-
config({ path: path.join(process.cwd(), ".env") });
8-
95
const port = parseInt(process.env.PORT ?? "1234");
106

117
await initLibrariesWithFeatures();

0 commit comments

Comments
 (0)