Update dockerfiles for npx versions, gdrive env credential paths

This commit is contained in:
colinmcneil
2024-12-17 13:15:58 -05:00
committed by Jim Clark
parent 368e3b23ca
commit 9ff603aef5
11 changed files with 38 additions and 12 deletions

View File

@@ -6,11 +6,14 @@ COPY src/filesystem /app
COPY tsconfig.json /tsconfig.json
RUN --mount=type=cache,target=/root/.npm npm install
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
FROM node:22-alpine AS release
COPY --from=builder /app/dist /app
COPY --from=builder /app/node_modules /app/node_modules
ENV NODE_ENV=production
WORKDIR /app

View File

@@ -7,12 +7,15 @@ WORKDIR /app
RUN --mount=type=cache,target=/root/.npm npm install
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
FROM node:22-alpine AS release
COPY --from=builder /app/dist /app
ENV NODE_ENV=production
WORKDIR /app
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/node_modules /app/node_modules
ENV NODE_ENV=production
CMD ["node", "dist/index.js"]

View File

@@ -56,7 +56,7 @@ To integrate this server with the desktop app, add the following to your app's s
"mcpServers": {
"gdrive": {
"command": "docker",
"args": ["run", "-i", "--rm", "ai/mcp-gdrive"]
"args": ["run", "-i", "--rm", "--mount", "type=bind,source=/Users/colinmcneil/Desktop/gcp-oauth.keys.json,target=/gcp-oauth.keys.json", "-v", "mcp-gdrive:/gdrive-server", "-e", "GDRIVE_OAUTH_PATH=/gcp-oauth.keys.json", "-e", "GDRIVE_CREDENTIALS_PATH=/gdrive-server/credentials.json", "ai/mcp-gdrive"]
}
}
}

View File

@@ -152,13 +152,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
const userQuery = request.params.arguments?.query as string;
const escapedQuery = userQuery.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
const formattedQuery = `fullText contains '${escapedQuery}'`;
const res = await drive.files.list({
q: formattedQuery,
pageSize: 10,
fields: "files(id, name, mimeType, modifiedTime, size)",
});
const fileList = res.data.files
?.map((file: any) => `${file.name} (${file.mimeType})`)
.join("\n");
@@ -175,7 +175,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
throw new Error("Tool not found");
});
const credentialsPath = path.join(
const credentialsPath = process.env.GDRIVE_CREDENTIALS_PATH || path.join(
path.dirname(new URL(import.meta.url).pathname),
"../../../.gdrive-server-credentials.json",
);
@@ -185,7 +185,7 @@ async function authenticateAndSaveCredentials() {
const auth = await authenticate({
keyfilePath: path.join(
path.dirname(new URL(import.meta.url).pathname),
"../../../gcp-oauth.keys.json",
process.env.GDRIVE_OAUTH_PATH || "../../../gcp-oauth.keys.json",
),
scopes: ["https://www.googleapis.com/auth/drive.readonly"],
});

View File

@@ -8,9 +8,12 @@ WORKDIR /app
RUN --mount=type=cache,target=/root/.npm npm install
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
FROM node:22-alpine AS release
COPY --from=builder /app/dist /app
COPY --from=builder /app/node_modules /app/node_modules
ENV NODE_ENV=production

View File

@@ -7,9 +7,12 @@ WORKDIR /app
RUN --mount=type=cache,target=/root/.npm npm install
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
FROM node:22-alpine AS release
COPY --from=builder /app/dist /app
COPY --from=builder /app/node_modules /app/node_modules
ENV NODE_ENV=production

View File

@@ -8,9 +8,12 @@ WORKDIR /app
RUN --mount=type=cache,target=/root/.npm npm install
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
FROM node:22-alpine AS release
COPY --from=builder /app/dist /app
COPY --from=builder /app/node_modules /app/node_modules
ENV NODE_ENV=production

View File

@@ -7,9 +7,12 @@ WORKDIR /app
RUN --mount=type=cache,target=/root/.npm npm install
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
FROM node:22-alpine AS release
COPY --from=builder /app/dist /app
COPY --from=builder /app/node_modules /app/node_modules
ENV NODE_ENV=production

View File

@@ -7,10 +7,12 @@ WORKDIR /app
RUN --mount=type=cache,target=/root/.npm npm install
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
FROM node:22-alpine AS release
COPY --from=builder /app/dist /app
COPY --from=builder /app/node_modules /app/node_modules
ENV NODE_ENV=production
WORKDIR /app

View File

@@ -7,9 +7,12 @@ WORKDIR /app
RUN --mount=type=cache,target=/root/.npm npm install
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
FROM node:22-alpine AS release
COPY --from=builder /app/dist /app
COPY --from=builder /app/node_modules /app/node_modules
ENV NODE_ENV=production

View File

@@ -8,9 +8,12 @@ WORKDIR /app
RUN --mount=type=cache,target=/root/.npm npm install
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
FROM node:22-alpine AS release
COPY --from=builder /app/dist /app
COPY --from=builder /app/node_modules /app/node_modules
ENV NODE_ENV=production