diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8148693 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:22-bookworm-slim AS base +WORKDIR /usr/local/app +COPY package.json . + +# Build the typescript code +FROM base AS dependencies +RUN npm install +COPY tsconfig.json . +COPY src ./src +RUN npm run build + +# Create the final production-ready image +FROM base AS release +RUN useradd -m appuser && chown -R appuser /usr/local/app +ENV NODE_ENV=production +RUN npm install --only=production +COPY --from=dependencies /usr/local/app/dist ./dist +USER appuser +CMD ["node", "dist/index.js"] \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 6383362..eda8e8b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -699,3 +699,11 @@ server.setRequestHandler(ReadResourceRequestSchema, async (request) => { const transport = new StdioServerTransport(); await server.connect(transport); + +["SIGINT", "SIGTERM"].forEach((signal) => { + process.on(signal, async () => { + console.log(`Received ${signal}, shutting down...`); + await server.close(); + process.exit(0); + }); +}); \ No newline at end of file