Skip to content

Commit

Permalink
fix(Healthcheck): Fixues docker healthcheck
Browse files Browse the repository at this point in the history
Points dockerfile to location of new healthcheck script

Fixes #699
  • Loading branch information
cblanc committed Jan 24, 2021
1 parent bf1e108 commit 12ec633
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ ARG PORT=8000
ENV PORT $PORT
EXPOSE $PORT

HEALTHCHECK --interval=5s CMD node healthcheck.js

RUN npm install --only=production --no-package-lock && \
npm cache clean --force

Expand All @@ -27,4 +25,6 @@ COPY ./public ./dist/public

WORKDIR /app/dist

HEALTHCHECK --interval=5s CMD node healthcheck.js

CMD [ "node", "server.js" ]
22 changes: 0 additions & 22 deletions healthcheck.js

This file was deleted.

22 changes: 22 additions & 0 deletions src/healthcheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import http from "http";

const options = {
host: "localhost",
port: process.env.PORT,
method: "GET",
timeout: 2000,
path: "/ping",
};

http
.request(options, (response) => {
if (response.statusCode === 200) return process.exit(0);
return process.exit(1);
})
.on("error", (error) => {
console.log(
`Healthcheck failed to ${options.host}:${options.port}/ping: ${error}`
);
return process.exit(1);
})
.end();

0 comments on commit 12ec633

Please sign in to comment.