Skip to content

Commit 67b5669

Browse files
env variable validation
1 parent a2928f8 commit 67b5669

File tree

5 files changed

+9
-17
lines changed

5 files changed

+9
-17
lines changed

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
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"@modelcontextprotocol/sdk": "^1.17.4",
1313
"ai": "^5.0.23",
1414
"dedent": "^1.6.0",
15-
"dotenv": "^17.2.1",
1615
"front-matter": "^4.0.2",
1716
"giget": "^2.0.0",
1817
"mcp-framework": "^0.2.15",
@@ -853,7 +852,7 @@
853852

854853
"diff-match-patch": ["[email protected]", "", {}, "sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw=="],
855854

856-
"dotenv": ["dotenv@17.2.1", "", {}, "sha512-kQhDYKZecqnM0fCnzI5eIv5L4cAe/iRI+HqMbO/hbRdTAeXDG+M9FjipUxNfbARuEg4iHIbhnhs78BCHNbSxEQ=="],
855+
"dotenv": ["dotenv@16.6.1", "", {}, "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow=="],
857856

858857
"dunder-proto": ["[email protected]", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.1", "es-errors": "^1.3.0", "gopd": "^1.2.0" } }, "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="],
859858

@@ -1675,10 +1674,6 @@
16751674

16761675
"@mastra/core/ai": ["[email protected]", "", { "dependencies": { "@ai-sdk/provider": "1.1.3", "@ai-sdk/provider-utils": "2.2.8", "@ai-sdk/react": "1.2.12", "@ai-sdk/ui-utils": "1.2.11", "@opentelemetry/api": "1.9.0", "jsondiffpatch": "0.6.0" }, "peerDependencies": { "react": "^18 || ^19 || ^19.0.0-rc", "zod": "^3.23.8" } }, "sha512-dIE2bfNpqHN3r6IINp9znguYdhIOheKW2LDigAMrgt/upT3B8eBGPSCblENvaZGoq+hxaN9fSMzjWpbqloP+7Q=="],
16771676

1678-
"@mastra/core/dotenv": ["[email protected]", "", {}, "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow=="],
1679-
1680-
"@mastra/deployer/dotenv": ["[email protected]", "", {}, "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow=="],
1681-
16821677
"@mastra/mcp/date-fns": ["[email protected]", "", {}, "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg=="],
16831678

16841679
"@modelcontextprotocol/inspector-cli/commander": ["[email protected]", "", {}, "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw=="],
@@ -1715,8 +1710,6 @@
17151710

17161711
"libsql/detect-libc": ["[email protected]", "", {}, "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw=="],
17171712

1718-
"mastra/dotenv": ["[email protected]", "", {}, "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow=="],
1719-
17201713
"mcp-framework/raw-body": ["[email protected]", "", { "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", "iconv-lite": "0.4.24", "unpipe": "1.0.0" } }, "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA=="],
17211714

17221715
"micromatch/picomatch": ["[email protected]", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],

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)