Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit ea078d9

Browse files
mikesir87nettofarah
authored andcommitted
Multi-stage build and signal handling (#55)
* Update image to use multi-stage build to not ship dev dependencies * Handle SIGINT and SIGTERM to allow app to stop cleanly
1 parent ee1df41 commit ea078d9

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
FROM node:6
2-
3-
COPY . /src
1+
FROM node:6 as build
42
WORKDIR /src
5-
3+
COPY package* ./
64
RUN npm install
5+
COPY . .
76
RUN make build
8-
RUN npm prune --production
7+
8+
FROM node:6
9+
WORKDIR /src
10+
COPY package* ./
11+
RUN npm install --production
12+
COPY --from=build /src/bin ./bin
13+
COPY --from=build /src/build ./build
14+
COPY --from=build /src/server ./server
915

1016
VOLUME /src
1117

bin/server

100644100755
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ let app = require('..');
1111
let port = process.env.PORT || 3000;
1212

1313
app.listen(port);
14+
15+
process.on('SIGINT', function () {
16+
process.exit();
17+
});
18+
19+
process.on('SIGTERM', function() {
20+
process.exit();
21+
})

0 commit comments

Comments
 (0)