Skip to content

Commit

Permalink
Update healthcheck to work with PORT variable
Browse files Browse the repository at this point in the history
  • Loading branch information
modem7 committed Sep 5, 2022
1 parent fb845c3 commit 36d1a9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ COPY --link /public ./public
COPY --link --from=builder /app/.next/standalone ./
COPY --link --from=builder /app/.next/static/ ./.next/static/

EXPOSE 3000
ENV PORT='3000'

HEALTHCHECK --interval=12s --timeout=12s --start-period=30s \
CMD node ./healthcheck.js

EXPOSE 3000
ENV PORT 3000
CMD ["node", "server.js"]
7 changes: 5 additions & 2 deletions healthcheck.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
var http = require("http");

const PORT = process.env.PORT || "3000";

var options = {
host: "localhost",
port: "3000",
port: PORT,
timeout: 2000,
};
var request = http.request(options, (res) => {
Expand All @@ -16,4 +19,4 @@ request.on("error", function (err) {
console.log("ERROR");
process.exit(1);
});
request.end();
request.end();

0 comments on commit 36d1a9c

Please sign in to comment.