From 36d1a9c7385c49010cfb55466e976b42ae3ca07b Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 5 Sep 2022 22:55:14 +0100 Subject: [PATCH] Update healthcheck to work with PORT variable --- Dockerfile | 5 +++-- healthcheck.js | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 026189ddd..3fa1367ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/healthcheck.js b/healthcheck.js index 8e2301f83..cd9b288ac 100755 --- a/healthcheck.js +++ b/healthcheck.js @@ -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) => { @@ -16,4 +19,4 @@ request.on("error", function (err) { console.log("ERROR"); process.exit(1); }); -request.end(); \ No newline at end of file +request.end();