Skip to content

Commit

Permalink
Merge pull request #9 from mikesir87/add-dockerfile
Browse files Browse the repository at this point in the history
Add Dockerfile
  • Loading branch information
Flux159 authored Dec 26, 2024
2 parents b0da3d0 + 89fbaa1 commit 2d42893
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 2d42893

Please sign in to comment.