Skip to content

Commit 566d69d

Browse files
committed
Add a Dockerfile for the cosmosdb-server service
Add a Dockerfile that uses Node.js 12.x to install the necessary project dependencies to run cosmosdb-server within a container. In addition, add support to the server itself to gracefully shutdown when given a subset of UNIX signals (e.g., SIGINT, SIGTERM).
1 parent 4285646 commit 566d69d

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Dockerfile
2+
node_modules

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:12-slim
2+
3+
WORKDIR /app
4+
5+
COPY package.json yarn.lock ./
6+
7+
RUN yarn install --production=false --frozen-lockfile
8+
9+
COPY . .
10+
11+
RUN yarn run build
12+
13+
ENTRYPOINT [ "node", "lib/cli.js" ]

src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,17 @@ export default (opts?: ServerOptions) => {
8787
}
8888
});
8989

90+
const gracefulShutdown = () => {
91+
console.debug("Attempting a graceful shutdown...");
92+
93+
server.close(() => {
94+
console.debug("Existing connections closed. Exiting...");
95+
process.exit(0);
96+
});
97+
};
98+
99+
process.on('SIGINT', gracefulShutdown);
100+
process.on('SIGTERM', gracefulShutdown);
101+
90102
return server;
91103
};

0 commit comments

Comments
 (0)